Collection interface
- If we want to represent a group of individual objects as a single entity then we should go for Collection interface.
- Collection interface defines the most common general methods which can be applicable for any Collection object.
- The following is the list of methods present in Collection interface.
- boolean add(Object o);
- boolean addAll(Collection c);
- boolean remove(Object o);
- boolean removeAll(Object o);
- boolean retainAll(Collection c); // To remove all objects except those present in c.
- void clear();
- boolean contains(Object o);
- boolean containsAll(Collection c);
- boolean isEmpty();
- int size();
- Object[] toArray();
- Iterator iterator();
There is no concrete class which implements Collection interface directly.
Collection interface