Java Array length Property
Example
Find out how many elements an array has:
String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
System.out.println(cars.length);
Definition and Usage
The length
property returns the length of an array.
This is a built-in Java property, and does not belong to the Java Arrays Class.
Note: The length
property must not be mistaken with the length()
method that is used for Strings.
Syntax
array.length
Related Pages
❮ Arrays Methods