0

Possible Duplicate:
Difference between int[] array and int array[]

Is int[] arr; functionally the same as int arr[];?

Community
  • 1
  • 1
  • Even more entertainingly, try: public int getIntArray()[]. – Owen Mar 03 '11 at 20:21
  • 2
    i feel int arr[] is worse: int[] arr follows TYPE VAR_NAME style, whereas int arr[] is more like TY VAR_NAME PE – iluxa Mar 03 '11 at 20:23
  • 2
    I find it amusing that what could easily have been written as a subjective question (which is better?) wasn't, and then it gets subjective answers and comments. – Isaac Truett Mar 03 '11 at 20:28

5 Answers5

5

Yes. You can put the braces in either place when declaring an array.

Bonus: you can even put 'em here: int []arr

Isaac Truett
  • 8,734
  • 1
  • 29
  • 48
1

Yes, the functionality is the same. You can have the braces anywhere.

int[] a,b,c[];

is equivalent to

int a[],b[],c[][];
dev_musings
  • 1,161
  • 1
  • 10
  • 17
1

It's just the matter of style. You can pick the style you like. They perform exactly the same. Some claim that if you write "int[] array", it will be clearer that it's an array of integer rather than writing "int array[]".

chepukha
  • 2,371
  • 3
  • 28
  • 40
0

It is, it's just to appease C++ developers they include int arr[]. (Or at least what I told in school)

kevingreen
  • 1,541
  • 2
  • 18
  • 40
0

Yes it's the same. int[] arr is more convenient though.

cretzel
  • 19,864
  • 19
  • 58
  • 71