Introduction to Java Collections Framework

Java Collections

Which Collection to Use

The following flowchart was provided by Sergiy Kovalchuk in his blog:

java collections flowchart

Java Collections Properties

properties of java collections
Java Collections Framework Overview

The following overview has been provided by Oracle. We will be using the Java Collections Framework throughout this course.

The Java platform includes a Collections Framework. A collection is an object that represents a group of objects (such as the classic List class). A collections framework is a unified architecture for representing and manipulating collections, enabling collections to be manipulated independently of implementation details.

Of all the collections included in the Java Collections Framework, we will make most extensive use of the List class in this course.

The primary advantages of a collections framework are that it:

Reduces programming effort by providing data structures and algorithms so you don't have to write them yourself.

Increases performance by providing high-performance implementations of data structures and algorithms. Because the various implementations of each interface are interchangeable, programs can be tuned by switching implementations.

Provides inter-operability between unrelated APIs by establishing a common language to pass collections back and forth.

Reduces the effort required to learn APIs by requiring you to learn multiple ad hoc collection APIs.

Reduces the effort required to design and implement APIs by not requiring you to produce ad hoc collections APIs.

Fosters software reuse by providing a standard interface for collections and algorithms with which to manipulate them.The collections framework consists of:

Collection interfaces. Represent different types of collections, such as sets, lists, and maps. These interfaces form the basis of the framework.

General-purpose implementations. Primary implementations of the collection interfaces.

Legacy implementations. The collection classes from earlier releases, Vector and Hashtable, were retrofitted to implement the collection interfaces.

Special-purpose implementations. Implementations designed for use in special situations. These implementations display nonstandard performance characteristics, usage restrictions, or behavior.

Concurrent implementations. Implementations designed for highly concurrent use.

Wrapper implementations. Add functionality, such as synchronization, to other implementations.

Convenience implementations. High-performance "mini-implementations" of the collection interfaces.

Abstract implementations. Partial implementations of the collection interfaces to facilitate custom implementations.

Algorithms. Static methods that perform useful functions on collections, such as sorting a list.

Infrastructure. Interfaces that provide essential support for the collection interfaces.

Array Utilities. Utility functions for arrays of primitive types and reference objects. Not, strictly speaking, a part of the collections framework, this feature was added to the Java platform at the same time as the collections framework and relies on some of the same infrastructure.

1 point
What is the best data structure for the application that requires no order and requires unique keys?

1 point
hat is the best data structure for the application that requires a sorted map?