File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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: 11955

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: 46349
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!