List, Set, and Map interfaces
The Java collections framework consists of classes and interfaces that implement a collection data structure. Collections are similar to arrays in that they can hold references to objects and can be managed as a group. The difference is that arrays require their capacity to be defined before they can be used, while collections can increase and decrease their size automatically as needed. You just add or remove an object reference to a collection, and the collection changes its size accordingly. Another difference is that collections cannot have their elements be primitive types, such as short
, int
, or double
. If you need to store such type values, the elements must be of a corresponding wrapper type, such as Short
, Integer
, or Double
.
Java collections support various algorithms for storing and accessing elements of a collection: an ordered list, a unique set, a dictionary (called a map in Java), a stack, a queue, and some others. All classes and interfaces...