Jcf

A set of classes and interfaces that implement commonly reusable data structures. It provides a standardized architecture for storing and manipulating groups of objects.

  • Flexible Size: Unlike standard arrays, which have a fixed size upon creation, collections can dynamically grow and shrink as you add or remove elements.
  • java.lang: This package is automatically imported into every Java file.
    • It contains fundamental classes like Object, String, System, etc., but not the Collections Framework, which is in java.util.

Hierarchy

		Collection
			|
+-----------+-----------+
|           |           |
List       Set        Queue
  • Note: Map is also part of the JCF but does not inherit from the Collection interface.

Collection Interface

  • This is the root interface for most collections.
  • It defines basic operations like adding (add()), removing (remove()), checking size (size()), and clearing (clear()).

List Interface

  • An ordered collection (sometimes called a sequence) that allows duplicate elements. Elements can be accessed by their integer index.
  • ArrayList, ArrayList (DSA)
  • LinkedList

Set Interface

Queue Interface FIFO

A collection used to hold elements prior to processing. Besides basic Collection operations, queues provide additional insertion, extraction, and inspection operations. Typically, they follow a First-In, First-Out (FIFO) order.

Map Interface 🗺️ (not in the hierarchy but part of Collections)

Note

  • Collection vs. Collections:
    • Collection (with a capital ‘C’) is an interface (java.util.Collection) that is the root of the collection hierarchy.
    • Collections (with an ‘s’) is a utility class (java.util.Collections) that provides static methods for operating on or returning collections.