0

I think I have seen both patterns in Java:

int array[] = { 1, 2, 3 };
int[] array = { 1, 2, 3 };

Are they both correct? Why are they both correct? Is one of them preferred/recommended?

My question is: when does the [] go after the type, and when does the [] go after the identifier when initialising arrays?

theonlygusti
  • 9,142
  • 8
  • 49
  • 93

0 Answers0