Brackets
We will talk more about the structure of computer programs later on, but for now all your programs should have the following format:
public class Name
{
public static void main(String[] args)
{
//statements, such as printing
}
}Again, this program should be stored in the file Name.java. The brackets in programs do not have to be arranged like the example above – there are many different styles that people use.
For example, this is the bracketing style that I prefer:
public class Name {
public static void main(String[] args) {
//statements, such as printing
}
}Additionally, your program does not have to be spaced like the example above. The following program is also valid Java code:
public class Name
{public static void main(String[] args){
//statements, such as printing
}}However, this program is much more difficult to read. It is a good idea to always indent (with a tab) every time you open a bracket. When you type the matching closing bracket, do not tab over that line.