I have recently been thinking about the difference between the two ways of defining an array:
int[] array
int array[]
Is there a difference?
I have recently been thinking about the difference between the two ways of defining an array:
int[] array
int array[]
Is there a difference?
There is no difference in functionality between both styles of declaration. Both declare array of int.
But
int[] a
keeps type information together and is more verbose so I prefer it.Both are equally valid. The
int puzzle[]
form is however discouraged, theint[] puzzle
is preferred according to the coding conventions. See also the official Java arrays tutorial:Note the last paragraph.
I recommend reading the official Sun/Oracle tutorials rather than some 3rd party ones. You would otherwise risk end up in learning bad practices.
Both are ok. I suggest to pick one and stick with it. (I do the second one)
The Java Language Specification says:
Thus they will result in exactly the same byte code.
In Java, these are simply different syntactic methods of saying the same thing.
The two commands are the same thing.
You can use the syntax to declare multiple objects:
see: http://java.sun.com/docs/books/jls/second_edition/html/arrays.doc.html