Difference between int[] array and int array[]

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

    No, these are the same. However

    byte[] rowvector, colvector, matrix[];
    

    is equivalent to:

    byte rowvector[], colvector[], matrix[][];
    

    Taken from Java Specification. That means that

    int a[],b;
    int[] a,b;
    

    are different. I would not recommend either of these multiple declarations. Easiest to read would (probably) be:

    int[] a;
    int[] b;
    

提交回复
热议问题