We can determine the length of an ArrayList
using its public method size()
, like
ArrayList arr = new ArrayL
It's defined in the Java language specification:
The members of an array type are all of the following:
- The
public final
fieldlength
, 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.