• Post Reply Bookmark Topic Watch Topic
  • New Topic

Array Creation Error..  RSS feed

 
Moguluri Ravi Kiran
Ranch Hand
Posts: 63
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Hello friends i am facing a problem given above...
commented as line 1 is successfully compiled & line 2 not..
please explain me why or suggest me any book for that..
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can writeororYou can only miss out the new int[] bit when you have the declaration and instantiation in the same statement. In the second case you have the declaration and instantiations in different statements, so the compiler won't be happy.

By the way, writinginstead ofcan be regarded as confusing code because the two pairs of [] are dissociated from each other.
 
Moguluri Ravi Kiran
Ranch Hand
Posts: 63
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much & thanks for suggetion.
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!