AP® Computer Science A glossary
Array length
Also called: length attribute
Course: AP® Computer Science A Shows up in: Unit 4: Data Collections
The number of elements in an array, set when the array is created and read with the length attribute (no parentheses).
Appears in the course and exam description (CED): 4.3.A.24.3.A.6
The length cannot change after creation. Write arr.length for an array, str.length() for a String and list.size() for an ArrayList.
double[] times = new double[5];
System.out.println(times.length);
System.out.println(times.length - 1);
Output:
5
4 Learn it properly, with a checkpoint 4.3 Array Creation and Access