This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler 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

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Differnce between array declaration" Watch "Differnce between array declaration" New topic

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)

fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11927

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

Joined: Oct 13, 2005
Posts: 45429
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:
subject: Differnce between array declaration
It's not a secret anymore!