-1

Like int [] i or int i [] is there any difference I'm curious

kelvin andre
  • 395
  • 5
  • 11
  • 1
    They are equivalent, but the first-style is [explicitly recommended](https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html). I suspect the second form is only allowed because that is the C-style, and Java was designed to be easy to learn for people coming from C (even though it is a pretty different language). – juanpa.arrivillaga Aug 30 '17 at 22:46
  • @juanpa.arrivillaga ["Brackets are allowed in declarators as a nod to the tradition of C and C++"](https://docs.oracle.com/javase/specs/jls/se8/html/jls-10.html#jls-10.2) so your suspicions are correct. – Andy Turner Aug 30 '17 at 22:53

1 Answers1

2

No, int[] i is the same as int i[], but the latter one is discouraged.

See the official documentation on Arrays:

However, convention discourages this form; the brackets identify the array type and should appear with the type designation.

Marvin
  • 13,325
  • 3
  • 51
  • 57