tags:

views:

130

answers:

3

I've been told that

int[] numbers 

and

int numbers[] 

are equivalent. I've only ever seen the former though. What impetus is there, if ever, to write the latter?

+6  A: 

None. It's just a legacy from C syntax. However, it should be noted that C and Java arrays are very different. Java arrays are more like a malloc-allocated pointer with a length field.

Matthew Flaschen
+5  A: 

Doesnt really matter, but, my personal preference is for int[] numbers as it more logically follows the class instance_name pattern.

After all you are really delcaring an "array of integers" called "numbers", the second form is slightly misleading as its more of declaring "an integer" called "numbers" oh and by the way its actually an array of "numbers".

James Anderson
A: 

just becoz of- the way earlier we used to declare in C. two options are available...chose as per ur convenience. No big deal, java provided new way of declaring array & remained the old way of declaring array also. Full freedom for programmer....cool stuff. no confusion at all.

Mansingh Shitole