Difference between int[] array and int array[]

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

    The Java Language Specification says:

    The [] may appear as part of the type at the beginning of the declaration,
    or as part of the declarator for a particular variable, or both, as in this
    example:
    
    byte[] rowvector, colvector, matrix[];
    
    This declaration is equivalent to:
    
    byte rowvector[], colvector[], matrix[][];
    

    Thus they will result in exactly the same byte code.

提交回复
热议问题