Collections Methods Flashcards
Collection boolean add(Element elem)
Adds elem into the underlying container
Collection void clear()
Removes all elements from the container
Collection boolean isEmpty()
Returns true if empty, false if not.
Collection Iterator iterator()
Returns an Iterator object for iterating over the container.
Collection int size()
Returns the number of elements in the container
Collection Object[] toArray()
Returns an array that has all elements in the container.
Collection boolean addAll(Collection extends element> coll)
Adds all the elements in coll into the underlying container
Collection boolean containsAll(Collection> coll)
Checks if all elements given in coll are present in the underlying container.
Collection boolean removeAll(Collection> coll)
Removes all elements from the underlying container that are also present in coll.
Collection boolean retainAll(Collection> coll)
Retains elements in the underlying container only if they are also present in coll; removes all other elements.
Iterator boolean hasNext()
Returns true if there are more elements to traverse.
Iterator E next()
Moves the iterator to the next element and returns that element.
Iterator void remove()
Removes the last visited element from the underlying container. next() must be called before calling remove, otherwise throws IllegalStateException.
ListIterator boolean hasPrevious()
Checks if the iterator has more elements to traverse in the previous direction.
ListIterator Element previous()
Moves the iterator to the next element and returns that next element in reverse direction()