I have recently been thinking about the difference between the two ways of defining an array:
int[] array
int array[]
They are semantically identical. The int array[]
syntax was only added to help C programmers get used to java.
int[] array
is much preferable, and less confusing.
There isn't any difference between the two; both declare an array of int
s. However, the former is preferred since it keeps the type information all in one place. The latter is only really supported for the benefit of C/C++ programmers moving to Java.
They are completely equivalent. int [] array
is the preferred style. int array[]
is just provided as an equivalent, C-compatible style.
The most preferred option is int[] a
- because int[]
is the type, and a
is the name.
(your 2nd option is the same as this, with misplaced space)
Functionally there is no difference between them.
In Java, these are simply different syntactic methods of saying the same thing.
There is no real difference; however,
double[] items = new double[10];
is preferred as it clearly indicates that the type is an array.