Where is array's length property defined?

前端 未结 7 807
悲哀的现实
悲哀的现实 2020-11-22 13:41

We can determine the length of an ArrayList using its public method size(), like

ArrayList arr = new ArrayL         


        
7条回答
  •  伪装坚强ぢ
    2020-11-22 14:23

    It's defined in the Java language specification:

    The members of an array type are all of the following:

    • The public final field length, which contains the number of components of the array. length may be positive or zero.

    Since there is a limitless number of array types (for every class there is a corresponding array type, and then there are multidimensional arrays), they cannot be implemented in a class file; the JVM has to do it on the fly.

提交回复
热议问题