Java Collections

About Collections Framework:

Collections are used to store, retrieve, manipulate, and communicate aggregate data. Collections represent data items that form a natural group, such as list of students, telephone directory etc.,

Java collections framework is a collection of interfaces and classes which helps in storing and processing the data efficiently.

The collections framework defines several interfaces. This section provides an overview of some of the important interfaces provided by Collections framework :

Collections Interface

Top of collections Hierarchy. This interface is the foundation to the entire collections framework which lists all the methods implemented by other classes.

List Interface

This extends Collection and an instance of List stores an ordered collection of elements.

Set Interface

This extends Collection to handle sets, which must contain unique elements.

Map Interface

This maps key value pairs.

We will look into some of the benefits of using Collections in Java.

Benefits of the Java Collections Framework

The Java Collections Framework provides the following benefits:

  • Reduces programming effort: By providing useful data structures and algorithms, the Collections Framework frees you to concentrate on the important parts of your program rather than on the low-level “plumbing” required to make it work. By facilitating interoperability among unrelated APIs, the Java Collections Framework frees you from writing adapter objects or conversion code to connect APIs.
  • Increases program speed and quality: This Collections Framework provides high-performance, high-quality implementations of useful data structures and algorithms. The various implementations of each interface are interchangeable, so programs can be easily tuned by switching collection implementations. Because you’re freed from the drudgery of writing your own data structures, you’ll have more time to devote to improving programs’ quality and performance.
  • Allows interoperability among unrelated APIs: The collection interfaces are the vernacular by which APIs pass collections back and forth. If my network administration API furnishes a collection of node names and if your GUI toolkit expects a collection of column headings, our APIs will interoperate seamlessly, even though they were written independently.
  • Reduces effort to design new APIs: This is the flip side of the previous advantage. Designers and implementers don’t have to reinvent the wheel each time they create an API that relies on collections; instead, they can use standard collection interfaces.
  • Allows software reuse: New data structures that conform to the standard collection interfaces are by nature reusable. The same goes for new algorithms that operate on objects that implement these interfaces.

References:

http://docs.oracle.com/javase/tutorial/collections/intro/index.html

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top