Array Lists
March 23rd, 2016
Lecture Code
Array Lists vs. Arrays
Array Lists can grow and shrink dynamically.
Arrays are static.
- Oracle Documentation
- import java.util.ArrayList;
- size() method
- add() method
- set(int, instance) method
- get(int) method
- remove(int) method
- Declaration: ArrayList<Type> myList;
- Allocation: myList = new ArrayList<Type>();
- Wrapper Classes: Byte, Short, Integer, Long, Float, Double, Character,
Boolean
Class Exercise
Take the 1D Array example that we developed (ArrayStuff) and
convert it to use an ArrayList instead of an array.