The ArrayList Class




An ArrayList is a collection class. It allows you to keep a list of objects (indexed at positions 0, 1, 2, etc.).

Example:

  
   private ArrayList<String> names = new ArrayList<String>();



Some common methods:

add(some object) - adds the object to the end of the list
add(position, some object) - inserts the object at the given position (index)
get(position) - returns the location of the object at the given position (index)
remove(position) - removes the object at the given position (index)
clear() - removes all objects from the list