[{“Name”:“Java SE 1.2”,“GroupName”:null},{“Name”:“Java SE 1.3”,“GroupName”:null},{“Name”:“Java SE 1.4”,“GroupName”:null},{“Name”:“Java SE 5”,“GroupName”:null},{“Name”:“Java SE 6”,“GroupName”:null},{“Name”:“Java SE 7”,“GroupName”:null},{“Name”:“Java SE 8”,“GroupName”:null},{“Name”:“Java SE 9 (Early Access)”,“GroupName”:null}]
The collections framework in java.util
provides a number of generic classes for sets of data with functionality that can’t be provided by regular arrays.
Collections framework contains interfaces for Collection<O>
, with main sub-interfaces List<O>
and Set<O>
, and mapping collection Map<K,V>
. Collections are the root interface and are being implemented by many other collection frameworks.
Collections are objects that can store collections of other objects inside of them. You can specify the type of data stored in a collection using Generics.
Collections generally use the java.util
or java.util.concurrent
namespaces.
Java 1.4.2 and below do not support generics. As such, you can not specify the type parameters that a collection contains. In addition to not having type safety, you must also use casts to get the correct type back from a collection.
In addition to Collection<E>
, there are multiple major types of collections, some of which have subtypes.
List<E>
is an ordered collection of objects. It is similar to an array, but does not define a size limit. Implementations will usually grow in size internally to accomodate new elements.Set<E>
is a collection of objects that does not allow duplicates.SortedSet<E>
is a Set<E>
that also specifies element ordering.Map<K,V>
is a collection of key/value pairs.SortedMap<K,V>
is a Map<K,V>
that also specifies element ordering.Java 5 adds in a new collection type:
Queue<E>
is a collection of elements meant to be processed in a specific order. The implementation specifies whether this is FIFO or LIFO. This obsoletes the Stack
class.Java 6 adds in some new subtypes of collections.
NavigableSet<E>
is a Set<E>
with special navigation methods built in.NavigableMap<K,V>
is a Map<K,V>
with special navigation methods built in.