The rules for code blocks within a language dictate where you can declare variables, how you "bracket" code, etc.
Java Code Blocks
Curly braces are used to bracket code blocks including classes and the methods within a class.
For Java, JavaScript, PHP, and C++, I prefer to put the first { at the end of the first line of the code block as in the example above because I see moreJava codeformatted that way.