0

I've seen examples such as:

Type arrayname[] = new Type[];

also as written as:

Type[] arrayname = new Type[]

I am quite confused about such expressions!

Where exactly should I put the []?

dave
  • 11,641
  • 5
  • 47
  • 65
tonyabracadabra
  • 319
  • 2
  • 10

1 Answers1

1

Any of the above are allowed. All produce the same bytecode. JLS-10.2 Array Variables says (in part)

The [] may appear as part of the type at the beginning of the declaration, or as part of the declarator for a particular variable, or both.

Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249