In the first example, all the type information is in one place - the type of the variable is "array of dataType
" so that's what the dataType[]
says.
Why would you have two aspects of the type information in different places - one with the element type name and one with the variable?
Note that you can do really confusing things:
int[] x[]; // Equivalent to int[][] x
and
int foo()[] // Equivalent to int[] foo()
Ick!
Also note that the array syntax is closer to the generic syntax if you later want to use a collection type instead of an array. For example:
String[] foo
to
List<String> foo
Basically, the int foo[]
syntax was only included in Java to make it look more like C and C++. Personally I think that was a mistake - it can never be removed from the language now, despite the fact that it's strongly discouraged :(