Although both syntaxes are equivalent, the syntax is int[] variableName; is preferred. Syntax int variableName[]; allowed only for ease of use by all C / C ++ programmers migrating to Java.
It can be argued that int[] x clearly states that the integer array is of type x, whereas in int x[] actual type is split into two parts: one before and the other after x , counting the integer as the type of x, which is an array that makes the ad less readable and potentially confusing for beginners.
The readability problem is compounded if the array has more dimensions, for example, all of these declarations are equivalent and valid:
int x[][][]; int[] x[][]; int[][] x[]; int[][][] x; // this one is the easiest to read!
Also note that the same considerations apply to all of these valid, equivalent method declarations (the return type is the same in all cases) - but again the latter is easier to read:
int m() [][][] {return null;} int[] m() [][] {return null;} int[][] m() [] {return null;} int[][][] m() {return null;} // this one is the easiest to read!
source share