Is there a functional difference between these methods?
public static void main(String[] args) { }
public static void main(String args[]) { }
The other answers are correct in that it doesn't make a difference. Let me just add two further points:
String ... args
is also valid now and in this case again makes no difference.
The different options to place your brackets do have a consequence, when you define multiple variables. In the following example the variable a
is not a String array, but b
is one and c
is an array of arrays of Strings.
String a, b[], c[][];
However, I have to suggest not to use this style for your code, as it can quickly become very confusing. For example, String [] b, c[];
means the same for b
and c
as above, but especially for c
this is non-obvious.
No, they have no difference. Though... I used to use the second way, until my girlfriend threatened to break if I continued doing it (not kidding). So now I prefer the first way, and I think it looks much better.
No, the above are equivalent. Arrays in Java can be declared in one of two ways, either:
String[] myarray;
or
String myarray[];