I have recently been thinking about the difference between the two ways of defining an array:
int[] array
int array[]
Is there a difference?
I have recently been thinking about the difference between the two ways of defining an array:
int[] array
int array[]
Is there a difference?
There is no difference, but Sun recommends putting it next to the type as explained here
There is no real difference; however,
is preferred as it clearly indicates that the type is an array.
They're the same. One is more readable (to some) than the other.
While the
int integers[]
solution roots in the C language (and can be thus considered the "normal" approach), many people findint[] integers
more logical as it disallows to create variables of different types (i.e. an int and an array) in one declaration (as opposed to the C-style declaration).No, these are the same. However
is equivalent to:
Taken from Java Specification. That means that
are different. I would not recommend either of these multiple declarations. Easiest to read would (probably) be:
No difference.
Quoting from Sun: