Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

about array  RSS feed

 
Albert Lee
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
are "array[][] a;" and "array[] a[];" eqivalent?
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to JLS 10.2 Array Variables, they are. Just make sure that the "array" type is defined somewhere
 
Bert Bates
author
Sheriff
Posts: 8945
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Albert -
Yes - they are the same... and from a style perspective:
int [ ] x; and int [ ] [ ] x;
are preferred over:
int x [ ]; or int x [ ] [ ];
which is certainly preferred over the legal but ugly:
int [ ] x [ ];
The reason is trying reading them out loud, from left to right.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!