Java Collections Interfaces Tutorial


Under the Java collection interfaces, we are going to discuss the below interfaces briefly.


  • Iterable interface
  • Collection Interface
  • List Interface
  • Set Interface
  • Queue Interface
  • Deque Interface
  • Map Interface
  • ListIterator Interface
  • SortedSet Interface
  • SortedMap Interface

Java Iterable Interface

The Java Iterable interface is the root interface for all the Collection interface and its descendant interfaces and classes except Map interface and its descendants. It provides functionalities to iterate over any Collection of objects.
Oracle documentation for Iterable Interface


Java Collection Interface

The Java Collection interface is the second interface after the Iterable interface in the collections hierarchy. It declares the functionalities that required for any collection.
Oracle documentation for Collection Interface


List Interface

  • Java List is an ordered collection of objects.
  • Java List can have duplicate items.
  • Java List allows multiple null elements.
  • Objects can access by their index (position in the list).
  • Objects can insert into the Java List by the desired index.
  • Objects can remove from the Java List by the desired index.
  • The Java List interface provides facility to insert and remove multiple elements at an arbitrary point in the list.
  • Java List interface is implemented by the classes

    AbstractList, AbstractSequentialList, ArrayList, AttributeList, CopyOnWriteArrayList, LinkedList, RoleList, RoleUnresolvedList, Stack, Vector.

Oracle documentation for List Interface

Java Set Interface

  • Java Set is an unordered collection of objects.
  • Java Set does not allow to have duplicate items.
  • Java Set only allows to have one null element.
  • Java Set interface is implemented by the classes

    AbstractSet, ConcurrentHashMap.KeySetView, ConcurrentSkipListSet, CopyOnWriteArraySet, EnumSet, HashSet, JobStateReasons, LinkedHashSet, TreeSet.

Oracle documentation for Set Interface


Java Queue Interface

  • Java Queue is a data structure to hold elements until processing them.
  • With Java Queue, we can order the elements in first-in-first-out (FIFO) manner (However, this is not necessary).
  • All new objects are inserted at the tail of the queue and removed at the head.
  • Java Queue can have duplicate items.
  • Since poll method returning null if the queue does not have any elements in it, developers must refrain inserting null elements into the queue if the implementation allows insertion of null elements.
  • Java Queue implementations generally do not allow insertion of null elements, but some implementations allow insertion of null elements.
  • Java Queue interface is implemented by the classes

    AbstractQueue, ArrayBlockingQueue, ArrayDeque, ConcurrentLinkedDeque, ConcurrentLinkedQueue, DelayQueue, LinkedBlockingDeque, LinkedBlockingQueue, LinkedList, LinkedTransferQueue, PriorityBlockingQueue, PriorityQueue, SynchronousQueue.

Oracle documentation for Queue Interface


Java Deque Interface

  • A linear collection that can insert and remove elements at both ends.
  • This interface extends the Java Queue interface.
  • When a deque is used as a Queue, we can perform FIFO (First-In-First-Out) behavioral functionalities.
  • When a deque is used as a Stack, we can perform LIFO (Last-In-First-Out) behavioral functionalities.
  • This interface does not provide support to access elements by its index.
  • Java Deque implementations generally do not restrict insertion of null elements, they are strongly encouraged not to do so.
  • Java Deque implementations return null if the deque is empty.
  • Java Deque interface is implemented by the classes

    ArrayDeque, ConcurrentLinkedDeque, LinkedBlockingDeque, LinkedList.

Oracle documentation for Deque Interface

Java Map Interface

  • Even though the Java Map interface and its descendants are part of the collections framework, it does not extends Iterable interface or Collection interfaces.
  • A Java Map cannot contain duplicate keys.
  • Each key can map to at most one value.
  • The Map interface provides 3 collection views, which allow a map's contents to be viewed as a set of keys, collection of values, or set of key-value mappings.
  • Java Map interface is implemented by the classes

    AbstractMap, Attributes, AuthProvider, ConcurrentHashMap, ConcurrentSkipListMap, EnumMap, HashMap, Hashtable, IdentityHashMap, LinkedHashMap, PrinterStateReasons, Properties, Provider, RenderingHints, SimpleBindings, TabularDataSupport, TreeMap, UIDefaults, WeakHashMap.

Oracle documentation for Map Interface


<< Java Collections Framework      Java ArrayList >>