![]() The collection class provides many useful methods for shuffling, reversing, sorting and searching collection objects. The Collections class contains static utility methods that either accepts or returns the collection. In addition to the above mentioned main interfaces and classes, there are two utility classes that are part of the Java collection framework. ![]() The main classes implementing the Set interface are Hashtable, HashMap, TreeMap and LinkedHashMap. ![]() Map interface does not guarantee the order of the elements, however, some implementations like TreeMap does. The map interface is a root interface and allows storing the key value pairs. The main classes implementing the Set interface are LinkedList, ArrayDeque and PriorityQueue. The Queue interface extends Collection interface and represents a collection that is usually ordered by FIFO (first in first out) order. The main classes implementing the Set interface are TreeSet, HashSet and LinkedHashSet. The Set interface extends the Collection interface and represents a collection that does not contain any duplicate elements (it can only have one null element as well). The main classes implementing the List interface are ArrayList and LinkedList. The elements contained in the List are ordered and can be inserted, accessed or searched based on their index. The List represents index based ordered collection of the objects. The List interface extends the Collections interface. The Collection interface is the root interface and provides common methods like add, remove, clear, contains, equals, hashcode, and iterator. Here is the pictorial representation of the Java Collection Framework hierarchy.Īs you can see from the above collection framework hierarchy, the Collection interface and Map interface are at the top of the hierarchy. ![]() Several other classes and interfaces implement and extend these two main interfaces to make the collection framework. The Java collection framework has two main interfaces, the Collection interface, and the Map interface. Java collection framework provides several interfaces and classes to help group the objects as a unit. A collection in Java is an object that stores a group of objects as a single unit. Java Collection framework tutorial with examples will help you understand how to use the collection classes in an easier way. ![]()
0 Comments
Leave a Reply. |