Engineering Full Stack Apps with Java and JavaScript
Collection Interface is the Root interface in the collection hierarchy.
JDK does not provide any direct implementations of this interface: it provides implementations of more specific subinterfaces like Set and List etc.
All child classes (direct or indirect) should provide minimum two constructors: a no argument constructor, which creates an empty collection, and a constructor with a single argument of type Collection, which creates a new collection with the same elements as its argument.
Overriden methods should throw UnsupportedOperationException if this collection does not support the operation.
may, but are not required to, throw an UnsupportedOperationException if the invocation would have no effect on the collection.
For example, invoking the addAll(Collection) method on an unmodifiable collection may, but is not required to, throw the exception if the collection to be added is empty.
add(E e)
Add element e
addAll(Collection<? extends E> c)
Add all from specified collection
clear()
clear collection
contains(Object o)
if o is present
containsAll(Collection<?> c)
if this collection contains all of the elements in the specified collection.
equals(Object o)
Check if meaningfully equal
hashCode()
Return hash code integer
isEmpty()
Check if empty
iterator()
Return an iterator
remove(Object o)
Remove o
removeAll(Collection<?> c)
Remove all elements present in the specified collection
retainAll(Collection<?> c)
Retains only the elements in this collection that are contained in the specified collection
size()
size of the collection
toArray()
convert to an array
toArray(T[] a)
runtime type of the returned array is that of the specified array.
Following methods from the above list are marked as optional:
add(E e)
addAll(Collection<? extends E> c)
clear()
remove(Object o)
removeAll(Collection<?> c)
retainAll(Collection<?> c)