Difference between int[] array and int array[]

前端 未结 25 3055
轻奢々
轻奢々 2020-11-21 07:18

I have recently been thinking about the difference between the two ways of defining an array:

  1. int[] array
  2. int array[]
  3. <
25条回答
  •  时光取名叫无心
    2020-11-21 08:01

    There is one slight difference, if you happen to declare more than one variable in the same declaration:

    int[] a, b;  // Both a and b are arrays of type int
    int c[], d;  // WARNING: c is an array, but d is just a regular int
    

    Note that this is bad coding style, although the compiler will almost certainly catch your error the moment you try to use d.

提交回复
热议问题