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

Related terms

Was this page helpful?

No names are ever shown, and every public comment is checked by us first. Please do not include personal details. To get a reply, email [email protected].

↑ Top

Enlarged view of the selected figure