What is the Java Collection Framework?

To explain the Java Collection Framework (JCF for short) it helps to go into more depth about the Framework components, so here’s a summary of the 3 primary components of the JCF:

The components of the Java collection framework

1.Interfaces – The framework defines abstract types (interfaces) such as List, Map, and Set.

2. Implementations – The framework provides reusable data structures. This is achieved through actual classes that implement the interfaces – like ArrayList which implements the List interface, and HashMap, which implements the Map interface. ArrayList is often used as an array implementation of a List and HashMap is often used as Hashtable implementation – so these are real data structures that can be used by programmers.

3. Algorithms – The framework provides algorithms that can be used on the collections classes. This includes things such as sorting, finding the min, and/or finding the max. We can use the static methods of the Collections class to do this – which would look something like Collections.sort(someArgsHere), Collections.max(someArgsHere), etc.

Implementation and interfaces are separated

Note that the interfaces in the collections can have many implementations. For example, the List interface has the classes ArrayList and LinkedList which implement it. This makes the code more generic.

So, the two primary components of the framework are the interfaces which define the abstract concepts like map, set, list, etc. and the concrete classes such as array list and linked list which implement the interfaces.

Follow Varoon Sahgal, author, on Google Plus