

A map cannot contain duplicate keys each key can map to at most one value. The Map interface enable us to store data in key-value pairs (keys should be immutable).

Some useful classes which implement Set interface are – ConcurrentSkipListSet, CopyOnWriteArraySet, EnumSet, HashSet, LinkedHashSet and TreeSet. Set interface does not provides no guarantee to return the elements in any predictable order though some Set implementations store elements in their natural ordering and guarantee this order. Sets do not allow the duplicate elements. Sets represents a collection of sorted elements. Some useful classes which implement List interface are – ArrayList, CopyOnWriteArrayList, LinkedList, Stack and Vector. Using lists, we can access elements by their integer index (position in the list), and search for elements in the list. Lists represents an ordered collection of elements. For example, List (indexed, ordered) and Set (sorted) interfaces implement this collection. It extends Iterable interface which adds support for iterating over collection elements using the “ for-each loop” statement.Īll other collection interfaces and classes (except Map) either extend or implement this interface. Collection interface provides all general purpose methods which all collections classes must support (or throw UnsupportedOperationException). CollectionĬollection interface is at the root of the hierarchy. The collections classes implement these interfaces and provide concrete functionalities.

The Collections framework is better understood with the help of core interfaces.

These collection classes provide very transparent support for all such operations using Collections APIs. The common operations in involve add, remove, update, sort, search and more complex algorithms. These ready-to-use collection classes solve lots of very common problems where we need to deal with group of homogeneous as well as heterogeneous objects. Java Collections framework is consist of the interfaces and classes which helps in working with different types of collections such as lists, sets, maps, stacks and queues etc. A collection, as name implies, is group of objects.
