Example
Find out how many elements an array has:
java
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 propertymust not be mistaken with the length() methodthat is used for Strings.
Syntax
java
array.length
Related Pages
Java Arrays Tutorial