What exception is thrown when you reach an index out of bounds in arraylist?
NullPointerException.
These methods are used to access and modify elements in an ArrayList.
.get() and .set()
How to initialize 2d array
<type>[][]
What is the exact syntax for importing ArrayList?
import java.util.ArrayList;
Is there an error with the following, and if so, what is it? ArrayList list = {0, 1, 2, 3}; System.out.println(list[3]);
Yes, you use .get() instead of [].
What type of memory is an ArrayList?
heap
List two non-obvious differences between array and ArrayList.
dynamically sized, store multiple types, (answers can vary)
ArrayList list = new ArrayList();list.add(“A”);list.add(“B”);list.add(0,”C”);list.add(“D”);list.set(2,”E”);list.remove(1);System.out.println(list);
"C E D"
What are the two different signatures of .add(), and what do they each do?
public boolean add(T item) adds to the end of the list. public void add(int index, T item) adds to index.
Determine whether each of the following is a method of ArrayList: .add(), .addAll(), .erase(), .removeFirst(), .set(), .size(), .length().
.add(), .addAll(), .set(), .size()
Is there an error with the following, and if so, what is it? ArrayList list = new ArrayList<int>(); list.add(1); list.add(Integer.parseInt("2"));
Yes, ArrayList can't store primitive types.
what row and column will arr[1][3] access
row 2 column 4