AP® Computer Science A glossary

ArrayList

Also called: ArrayList<E>

Course: AP® Computer Science A Shows up in: Unit 4: Data Collections

A java.util class for a list of object references that can grow and shrink; ArrayList<E> names the element type E.

Appears in the course and exam description (CED): 4.8.A.14.8.A.24.8.A.34.8.A.44.8.A.6

The constructor ArrayList() builds an empty list. Indexes run from 0 to size() - 1. Using ArrayList<E> lets the compiler catch type errors that would otherwise appear at run time.

ArrayList<String> songs = new ArrayList<String>();
songs.add("Intro");
songs.add("Finale");
System.out.println(songs + " " + songs.size());

Output:

[Intro, Finale] 2
Learn it properly, with a checkpoint 4.8 ArrayList Methods

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