The Java collections framework (JCF) popularly called, as Interface is a collection of classes and interfaces that execute commonly reusable collection data structures. Despite being called as Framework , it works like library.
The JCF provides both interfaces that define various collections and classes that implement them.
Framework is set of reusable software program that forms the basis for an application. Framework makes it easy to built an application due to having inbuilt set of classes and interfaces as against earlier days when it was very tedious to develop complex web applications.
There are several Frameworks such as Struts, Turbine, Tapestry, Web Work, Cocoon, Spring, Maverick, Echo, SOFIA, Verge, Anvil, Jaffa, Japple, JPublish, Jucas, Myfaces, WebOnSwing, Chrysalis, VRaptor, Swinglets, Milestone, SwingWeb, Wicket, Trimpath Junction, Macaw, Barracuda, Calyxo, Makumba, Rife, DWR, JSPWidget, JOSSO, JAT, OpenXava, Stripes, Click, ZK, WingS, Helma, Caramba, Restlet, Brill, jZeno, Ztemplates, Aranea Web Framework, RSF, Strecks, Hamlets, Google Webtoolkit, ThinWire, Pustefix, Roma Meta Framework, Aurora, jWic, Mentawai, fleXive, Vroom, AribaWeb, Induction, SerfJ, Flower framework, Sombrero, SerfJ, Playframework, JVx, Pandora, Vaadin, wro4j developed so far for developing web, local and desktop applications.
In Java , some most common frameworks such as Struts, Struts 2, Hibernate, JSF, Tapestry, JUnit, Log4j, Spring etc are used to develop different apps. Now, programmers can select any one or more framework for developing apps.
Like any particular thing, Frameworks are designed to achieve some certain goals like easy to use and implement, highly accurate and scalable, must not interfere in other similar collections but must work with great interoperability.
Frameworks are designed to use and implement in as readymade form means frameworks can be used in as-it-is form.
Framework architecture consists of frozen spots and hot spots (a virtual name), which are the basic components. The frozen spots define the overall architecture of a software system while hot spots represent those parts where the programmers add their own code to add the functionality specific to their own projects using Framework.
In an object-oriented environment, a framework consists of abstract and concrete classes. Instantiation of such a framework consists of composing and subclassing the existing classes.
When developing a concrete software system with a software framework, developers utilize the hot spots according to the specific needs and requirements of the system that means the user-defined classes (for example, new subclasses), receive messages from the predefined framework classes. Developers usually handle this by implementing superclass abstract methods.
No matter which Framework you are using but remember, each framework contains an integrated architecture that comprises of following three collections:
It consists of several interfaces, and classes that implement those interfaces, contained within the java.util package. It provides tools for maintaining a data container of objects.
Implementations, i.e., Classes:
Java collections framework is a set of classes and interfaces that are used to implement reusable collection data structures.
Algorithms refers to the logic used for performing all sorts of computations. The algorithms in Frameworks must be polymorphic - same method can be used on many different implementations of the appropriate collection interface.
Moreover, the framework defines several map interfaces and classes:
The collection Interface:
The collections framework defines several interfaces. Have a brief look:
The Collections Framework is made up of a set of interfaces for storing and manipulating groups of data into a single unit. It consists of several interfaces, and classes that implement those interfaces, contained within the java.util package. It provides tools for maintaining a data container of objects.
The List interface extends the Collection interface to define an ordered collection. It is also known as the sequence collection, which permits duplicates element to accommodate in the set but does not map a key value to an object. It permits one or more elements to be null.
The Set interface extends the Collection interface. It neither contains duplicate elements nor maps a key value to an object. It permits a single element to be null.
This collection extends Set to handle sorted sets.
A Map is an object that maps keys to values. It is not an extension of the collection interface rather it has own interface hierarchy. Map provides a more general way for storing elements without containing duplicate keys.
The Map interface's entrySet( ) method returns a set of map . These sets are called as Map.Entry object.
The SortedMap interface extends the Map interface which maintains its elements in ascending order. Working with a SortedMap is just similar to a SortedSet except, the sort is done on the map keys.
Enumerate means get one at a time. As name is telling, the Enumeration interface have functions by which you can obtain one element at a time from the collection of object.
The Collection Classes:
Java provides a set of standard collection classes that implement Collection interfaces. Some of them given below in brief:
Used to declare common characteristics of a subclass.
AbstractList class is an abstract class, which extends the class AbstractCollection and implements the interface List.
AbstractSequentialList class is an abstract class and it extends the class AbstractList. This class reduces the effort needed to implement List interface returned by a 'sequential access' data store.
LikedList implements List interface, which perform all operation like add, remove, delete etc. LinkedList class provides method to insert, remove, to get the element, insert at the beginning.
ArrayList is a class that extends AbstractList and implements List Interface.
The AbstractSet class extends the class AbstractCollection and implements the interface Set.
A HashSet is a collection set that neither allows duplicate elements nor order or position its elements.
It is an ordered version of HashSet that maintains doubly-Linked list and display the content in the same order as you inserted.
TreeSet is similar to TreeMap that stores its elements in a tree and maintain order of its elements based on their values.
AbstractMap is an abstract class which extends the class Object and implements the Map interface.
The Map interface maps unique keys to value means it associate value to unique keys which you use to retrieve value at a later date.
A TreeMap is a Map class in java. It is available in java.util package in java. The TreeMap class extands AbstractMap class and implements SortedMap interface. It stores element in sorted order in java.
WeakHashMap class is defined in java.util package. You can say it is Hashtable based Map which implements weak keys.
The Class LinkedHashMap is an extension of HashMap with specific feature of retaining the insertion order in the order, in which they were inserted.
The IdentityHashMap class implements the Map interface with a hash table, using reference-equality in place of object-equality when comparing keys (and values).
The Collection Algorithms:
The collections framework defines several algorithms that can be applied to collections and maps. These algorithms are defined as static methods within the Collections class such as EMPTY_SET, EMPTY_LIST, and EMPTY_MAP. All are immutable.
Liked it! Share this Tutorial