Difference between int[] array and int array[]

前端 未结 25 2827
轻奢々
轻奢々 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:17

    They are the same, but there is an important difference between these statements:

    // 1.
    int regular, array[];
    // 2.
    int[] regular, array;
    

    in 1. regular is just an int, as opposed to 2. where both regular and array are arrays of int's.

    The second statement you have is therefore preferred, since it is more clear. The first form is also discouraged according to this tutorial on Oracle.

    0 讨论(0)
提交回复
热议问题