This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Differnce between array declaration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Differnce between array declaration" Watch "Differnce between array declaration" New topic
Author

Differnce between array declaration

Phillipe Rodrigues
Ranch Hand

Joined: Oct 30, 2007
Posts: 165
What is the basic difference between the below(1),(2)declarations?

int[] var;............................(1)
int var[];.............................(2)


Thanks,
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11853
    
  18

the first one is perferred by most people, but otherwise, there isn't a difference.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 43900
    
  32
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Differnce between array declaration
 
It's not a secret anymore!