Collections

What is it?

Java Collections framework: available, efficient, bug-free implementations of many key data structures

Most classes are in java.util.*

Collections framework

https://docs.oracle.com/javase/8/docs/technotes/guides/collections/overview.html

  1. A collection is an object that represents a group of objects (such as the classic Vector class).
  2. A collections framework is a unified architecture (interface and classes) for representing and manipulating collections (group of objects), enabling collections to be manipulated independently of implementation details.
  3. Java collections framework provides a standard programming interface to many of the most common abstractions, without burdening the programmer with too many procedures and interfaces.

Primary advantages

The primary advantages of a collections framework are that it:

  1. Reduces programming effort by providing data structures and algorithms so you don’t have to write them yourself.
  2. 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.
  3. Provides interoperability between unrelated APIs by establishing a common language to pass collections back and forth.
  4. Reduces the effort required to learn APIs by requiring you to learn multiple ad hoc collection APIs.
  5. Reduces the effort required to design and implement APIs by not requiring you to produce ad hoc collections APIs.
  6. Fosters software reuse by providing a standard interface for collections and algorithms with which to manipulate them.

What does the collections framework consists of?

The collections framework consists of:

  1. Collection interfaces. Represent different types of collections, such as sets, lists, and maps. These interfaces form the basis of the framework.
  2. General-purpose implementations. Primary implementations of the collection interfaces.
  3. Legacy implementations. The collection classes from earlier releases, Vector and Hashtable, were retrofitted to implement the collection interfaces.
  4. Special-purpose implementations. Implementations designed for use in special situations. These implementations display nonstandard performance characteristics, usage restrictions, or behavior.
  5. Concurrent implementations. Implementations designed for highly concurrent use.
  6. Wrapper implementations. Add functionality, such as synchronization, to other implementations.
  7. Convenience implementations. High-performance “mini-implementations” of the collection interfaces.
  8. Abstract implementations. Partial implementations of the collection interfaces to facilitate custom implementations.
  9. Algorithms. Static methods that perform useful functions on collections, such as sorting a list.
  10. Infrastructure. Interfaces that provide essential support for the collection interfaces.
  11. 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.

Collection Interfaces

https://docs.oracle.com/javase/8/docs/api/java/util/Collection.html

Collection implementations

https://docs.oracle.com/javase/8/docs/technotes/guides/collections/overview.html

Tags

  1. Collections - Arrays
  2. Collections - Iterators and Enumeration
  3. Collections - Java List interface
    1. Collections - Vector
    2. Collections - Vectors vs Arrays
    3. Collections - ArrayList
    4. Collections - Linked lists
    5. Collections - Linked List vs Arrays and ArrayLists
    6. Collections - Arraylist vs Arrays
    7. Collections - ArrayList vs Vector
    8. Collections - Comparing two lists
    9. Collections - Sorting ArrayList of user-defined objects
  4. Collections - Map interface
  5. Collections - Set interface
  6. Collections - Synchronized collections
  7. Java Streams Api
  8. Avoid if-else statements using collections
  9. Collections - Iterable collections and Iterators
  10. Collections - Reconcile objects in two collections
  11. Collections - Infinite Lists
  12. Collections - Helpful utility libraries
  13. ConcurrentModificationException

Links to this note