Please enable JavaScript to use CodeHS

AP CSA: VAR-2.D.7

CodeHS Lessons

The following ArrayList methods—including what they do and when they are used—are part of the Java Quick Reference— ● int size()- Returns the number of elements in the list ● int size()- Returns the number of elements in the list ● void add(int index, E obj) - Inserts obj at position index (0 <= index <= size), moving elements at position index and higher to the right (adds 1 to their indices) and adds 1 to size ● E get(int index) - Returns the element at position index in the list ● E set(int index, E obj)— Replaces the element at position index with obj; returns the element formerly at position index ● E remove(int index)— Removes element from position index, moving elements at position index + 1 and higher to the left (subtracts 1 from their indices) and subtracts 1 from size; returns the element formerly at position index

Standard
7.2 ArrayList Methods
Standard
5.5 ArrayList Methods
Standard
7.5 ArrayList Methods
Standard
14.2 ArrayList Methods
Standard
13.2 ArrayList Methods