The collection classes
The collection framework has the following classes for all occasions:
List
: This is an ordered collection that supports indexed access to elements and allows duplicate elementsSet
: This is a collection of elements in which each element can occur only onceQueue
: This is a collection that can be manipulated at both endsMap
: This is a collection of key-value pairs where each element is accessible by a unique key
All of them define their own specific way to add or remove elements from collections. Let's discuss each of them.
List
The List
class implements the Iterable interface and intensively uses the indexed order to iterate over elements in the collection. The List
class can be of a fixed or variable length. A fixed-length list can only be created by a constructor with a specific number of elements: new List(5)
. The fixed-length type has restrictions on all operations changing the length of the list and finishing with UnsupportedError
. The features of the fixed-length...