ArrayLists

Cards (9)

  • import java.util.ArrayList; : imports the ArrayList class
  • ArrayList<Datatype> ArrayListname = new ArrayList<Datatype>();
  • ArrayList<Datatype> ArrayListname = new ArrayList<Datatype>();
  • ArrayListname.add(element) - Adds an element to the end of the list.
  • ArrayListname.set(index,element) - Sets the value of the element at the specified index. Replaces the element currently at that position.
  • ArrayListname.remove(index) - Removes the element at the specified index.
  • ArrayListname.size() - Finds the number of elements currently stored in the arraylist.
  • ArrayListname.get(index) - Retrieves the element at the specified index.
  • ArrayListname.add(index,element) - Adds an element at the specified index. It will shift the element currently at that position to the right and any other subsequent elements.