private String[][] var[]
This code compiles. But shouldn\'t they make the array on type or variable?
The Java Language Specification says
"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"
in JLS 10.2 . In my opinion square brackets ([]
) in "types" make more sense of an array than that is in declared variables. But in order to confirm to the tradition of C/C++ it was done as the text says in JLS. Another thing is , mixing the square bracket with both types and variables would be confusing to the readers/programmers.