Methods for the collection class.
Boolean add (Object) | Ensures that the collection contains the argument. Returns false if it doesn't add the argument.1 |
Boolen addAll (Collection) | Adds all the elements in the argument. Returns true if any elements were added.1 |
void clear () | Removes all the elements in the collection. |
Boolean contains (Object) | True if the collection contains the argument. |
Boolean containsAll (Collection) | True if the collection contains all the elements in the argument. |
Boolean isEmpty () | True if the collection has no elements. |
Iterator iterator () | Returns an Iterator that you can use to move through the elements in the collection. |
Boolean remove (Object) | If the argument is in the collection, one instance of that element is removed. Returns true if a removal occurred.1 |
Boolean removeAll (Collection) | Removes all the elements that are contained in the argument. Returns true if any removals occurred.1 |
Boolean retainAll (Collection) | Retains only elements that are contained in the argument (an "intersection" from set theory). Returns true if any changes occurred.1 |
int size () | Returns the number of elements in the collection. |
Object [] toArray () | Returns an array containing all the elements in the collection. |
1This is an "optional" method, which means it might not be implemented by a particular collection. If not, that method throws an UnsupportedOperationException |