The following is the obvious and usual array declaration and initialization in Java.
int r[], s[]; //<-------
r=new int[10];
s=new int[10];
<
The sane way of declaring a variable is
type name
So if type is int[]
, we should write
int[] array
Never write
int array[]
it is gibberish (though it's legal)
Look at JLS on Arrays:
The
[]
may appear as part of the type at the beginning of the declaration, or as part of the declarator for a particular variable, or both.
and
Brackets are allowed in declarators as a nod to the tradition of C and C++. The general rules for variable declaration, however, permit brackets to appear on both the type and in declarators, so that the local variable declaration:
float[][] f[][], g[][][], h[]; // Yechh!
is equivalent to the series of declarations:
float[][][][] f; float[][][][][] g; float[][][] h;
So for example:
int []p, q[];
is just
int[] p, q[]
which is in fact
int p[]; int q[][]
The rest are all similar.