Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Differnce between array declaration

 
Phillipe Rodrigues
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the basic difference between the below(1),(2)declarations?

int[] var;............................(1)
int var[];.............................(2)
 
fred rosenberger
lowercase baba
Bartender
Posts: 12180
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the first one is perferred by most people, but otherwise, there isn't a difference.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49733
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to somewhere on the Sun site int[] array is preferred because it makes it clear that the type of the variable is an array.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic