Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

about array

 
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: 8898
5
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic