๐Ÿ—’๏ธ Ben's Notes

Collections

An overview of all the Collections in Java.

Collection is a Java interface for common abstract data types that store multiple items in them.

Sub-Interfaces #

Common Functions #

  • Membership tests contains() and containsAll() that can determine whether or not an element is in the collection.
  • size() to get the number of items in the collection.
  • isEmpty() returns true if there is nothing in the collection.
  • iterator() returns an Iterator object to go through all the values in the collection.
  • toArray() converts the collection to a standard Java array.
  • Optional functions that arenโ€™t implemented in the interface: add, addAll, clear, remove, removeAll, retainAll (intersection)
    • Throws UnsupportedOperationException if not implemented.