Java Collection Types Introduction
Java Collection Types Introduction
In Java, a collection refers to a group of objects or elements that are grouped together as a single unit.
The Java Collections Framework, which is part of the Java Standard Edition library (`java.util` package),
provides a set of interfaces and classes to represent and manipulate collections of objects.
1. **Interfaces:** The framework includes several core interfaces such as `Collection`, `List`, `Set`, `Map`,
etc., which define common methods and behaviors for collections.
2. **Classes:** Java provides concrete implementations of these interfaces, like `ArrayList`, `LinkedList`,
`HashSet`, `HashMap`, and many others.
3. **Dynamic Size:** Unlike arrays, most collection classes can dynamically grow or shrink in size,
providing flexibility in managing varying amounts of data.
4. **Generic Types:** Collections are often parameterized with generic types to ensure type safety and
allow the storage of a specific type of elements.
- **Collection:** The root interface for most collection types. It includes basic operations like `add`,
`remove`, `contains`, etc.
- **List:** An ordered collection that allows duplicate elements. Common implementations include
`ArrayList` and `LinkedList`.
- **Set:** An unordered collection that does not allow duplicate elements. Common implementations
include `HashSet` and `TreeSet`.
- **Map:** An object that maps keys to values. Common implementations include `HashMap` and
`TreeMap`.
- **Queue:** A collection designed for holding elements prior to processing. Common implementations
include `LinkedList` and `PriorityQueue`.
The Java Collections Framework provides a standardized way of working with collections, making it
easier for developers to write code that can work seamlessly with different types of collections.
All Java Collection Types:
• Dynamic array
• List
• Hash table
• Priority Queue
• Double-ended Queue
• Array
• EnumMap
• Linked List
• TreeSet
• LinkedHashSet
• Queue
• EnumSet
• AbstractSet
• ConcurrentLinkedQueue
• HashSet
• Set
• Stack
• SortedSet
• Class
• PriorityBlockingQueue