Java allows this:
class X{
int i,j[]; // j is an array, i is not
}
and even worse, it allows this:
class X{
int foo(String bar)[][][] // foo actually returns int[][][]
{ return null; }
}
Okay, the reason for this might be that it was lent from C/C++. However, Java meant to be easier than C/C++. Why did the Java inventors decide to allow this hard-to-read construct. The convoluted types of C where the variable name is in the middle of the type are just hard to read and provoke programming errors.
Especially the brackets behind the method signature. I have never seen these in use and that is for a good reason. No one looks behind the signature when checking the return type of a method. While the first example may save some keystrokes (because int
does not have to be written twice), the brackets behind the signature do not even save any, so I see absolutely no gain here.
So is there a good reason for this (especially the second one) that I am missing?