<s>
The	O
Java	B-Language
collections	I-Language
framework	I-Language
is	O
a	O
set	O
of	O
classes	O
and	O
interfaces	B-Language
that	O
implement	O
commonly	O
reusable	O
collection	B-Application
data	B-General_Concept
structures	I-General_Concept
.	O
</s>
<s>
Although	O
referred	O
to	O
as	O
a	O
framework	B-Architecture
,	O
it	O
works	O
in	O
a	O
manner	O
of	O
a	O
library	B-Library
.	O
</s>
<s>
The	O
collections	B-Language
framework	I-Language
provides	O
both	O
interfaces	B-Language
that	O
define	O
various	O
collections	O
and	O
classes	O
that	O
implement	O
them	O
.	O
</s>
<s>
Collection	B-Application
implementations	O
in	O
pre-JDK	O
1.2	O
versions	O
of	O
the	O
Java	B-Language
platform	O
included	O
few	O
data	B-General_Concept
structure	I-General_Concept
classes	O
,	O
but	O
did	O
not	O
contain	O
a	O
collections	B-Language
framework	I-Language
.	O
</s>
<s>
The	O
standard	O
methods	O
for	O
grouping	O
Java	B-Language
objects	O
were	O
via	O
the	O
array	O
,	O
the	O
Vector	O
,	O
and	O
the	O
Hashtable	B-Algorithm
classes	O
,	O
which	O
unfortunately	O
were	O
not	O
easy	O
to	O
extend	O
,	O
and	O
did	O
not	O
implement	O
a	O
standard	O
member	O
interface	O
.	O
</s>
<s>
To	O
address	O
the	O
need	O
for	O
reusable	O
collection	B-Application
data	B-General_Concept
structures	I-General_Concept
,	O
several	O
independent	O
frameworks	O
were	O
developed	O
,	O
the	O
most	O
used	O
being	O
Doug	O
Lea	O
's	O
Collections	O
package	B-Language
,	O
and	O
ObjectSpace	O
Generic	O
Collection	B-Application
Library	B-Library
(	O
JGL	O
)	O
,	O
whose	O
main	O
goal	O
was	O
consistency	O
with	O
the	O
C++	B-Language
Standard	B-Application
Template	I-Application
Library	I-Application
(	O
STL	O
)	O
.	O
</s>
<s>
The	O
collections	B-Language
framework	I-Language
was	O
designed	O
and	O
developed	O
primarily	O
by	O
Joshua	O
Bloch	O
,	O
and	O
was	O
introduced	O
in	O
JDK	O
1.2	O
.	O
</s>
<s>
It	O
reused	O
many	O
ideas	O
and	O
classes	O
from	O
Doug	O
Lea	O
's	O
Collections	O
package	B-Language
,	O
which	O
was	O
deprecated	O
as	O
a	O
result	O
.	O
</s>
<s>
Sun	O
Microsystems	O
chose	O
not	O
to	O
use	O
the	O
ideas	O
of	O
JGL	O
,	O
because	O
they	O
wanted	O
a	O
compact	O
framework	B-Architecture
,	O
and	O
consistency	O
with	O
C++	B-Language
was	O
not	O
one	O
of	O
their	O
goals	O
.	O
</s>
<s>
Doug	O
Lea	O
later	O
developed	O
a	O
concurrency	B-Operating_System
package	B-Language
,	O
comprising	O
new	O
Collection-related	O
classes	O
.	O
</s>
<s>
An	O
updated	O
version	O
of	O
these	O
concurrency	B-Operating_System
utilities	O
was	O
included	O
in	O
JDK	O
5.0	O
as	O
of	O
JSR	B-Language
166	I-Language
.	O
</s>
<s>
Almost	O
all	O
collections	O
in	O
Java	B-Language
are	O
derived	O
from	O
the	O
java.util.Collection	O
interface	O
.	O
</s>
<s>
Collection	B-Application
defines	O
the	O
basic	O
parts	O
of	O
all	O
collections	O
.	O
</s>
<s>
The	O
interface	O
states	O
the	O
add( )	O
and	O
remove( )	O
methods	O
for	O
adding	O
to	O
and	O
removing	O
from	O
a	O
collection	B-Application
respectively	O
.	O
</s>
<s>
Also	O
required	O
is	O
the	O
toArray( )	O
method	O
,	O
which	O
converts	O
the	O
collection	B-Application
into	O
a	O
simple	O
array	O
of	O
all	O
the	O
elements	O
in	O
the	O
collection	B-Application
.	O
</s>
<s>
Finally	O
,	O
the	O
contains( )	O
method	O
checks	O
if	O
a	O
specified	O
element	O
is	O
in	O
the	O
collection	B-Application
.	O
</s>
<s>
The	O
Collection	B-Application
interface	O
is	O
a	O
subinterface	O
of	O
java.lang.Iterable	O
,	O
so	O
any	O
Collection	B-Application
may	O
be	O
the	O
target	O
of	O
a	O
for-each	O
statement	O
.	O
</s>
<s>
All	O
collections	O
have	O
an	O
iterator	O
that	O
goes	O
through	O
all	O
of	O
the	O
elements	O
in	O
the	O
collection	B-Application
.	O
</s>
<s>
Additionally	O
,	O
Collection	B-Application
is	O
a	O
generic	O
.	O
</s>
<s>
Any	O
collection	B-Application
can	O
be	O
written	O
to	O
store	O
any	O
class	O
.	O
</s>
<s>
For	O
example	O
,	O
can	O
hold	O
strings	O
,	O
and	O
the	O
elements	O
from	O
the	O
collection	B-Application
can	O
be	O
used	O
as	O
strings	O
without	O
any	O
casting	O
required	O
.	O
</s>
<s>
Note	O
that	O
the	O
angled	O
brackets	O
can	O
hold	O
a	O
type	O
argument	O
that	O
specifies	O
which	O
type	O
the	O
collection	B-Application
holds	O
.	O
</s>
<s>
There	O
are	O
three	O
generic	O
types	O
of	O
collection	B-Application
:	O
ordered	O
lists	O
,	O
dictionaries/maps	O
,	O
and	O
sets	O
.	O
</s>
<s>
The	O
base	O
interfaces	B-Language
for	O
ordered	O
lists	O
are	O
called	O
List	O
and	O
Queue	O
.	O
</s>
<s>
Lists	O
are	O
implemented	O
in	O
the	O
collections	B-Language
framework	I-Language
via	O
the	O
java.util.List	O
interface	O
.	O
</s>
<s>
java.util.ArrayList	O
,	O
which	O
implements	B-Language
the	O
list	O
as	O
an	O
array	O
.	O
</s>
<s>
java.util.LinkedList	O
.	O
</s>
<s>
Stacks	O
are	O
created	O
using	O
java.util.Stack	O
.	O
</s>
<s>
java.util.Stack	O
is	O
a	O
standard	O
implementation	O
of	O
a	O
stack	O
provided	O
by	O
Java	B-Language
.	O
</s>
<s>
It	O
extends	O
class	O
java.util.Vector	O
with	O
five	O
operations	O
that	O
allow	O
a	O
vector	O
to	O
be	O
treated	O
as	O
a	O
stack	O
.	O
</s>
<s>
The	O
java.util.Queue	O
interface	O
defines	O
the	O
queue	O
data	B-General_Concept
structure	I-General_Concept
,	O
which	O
stores	O
elements	O
in	O
the	O
order	O
in	O
which	O
they	O
are	O
inserted	O
.	O
</s>
<s>
This	O
interface	O
is	O
implemented	O
by	O
java.util.LinkedList	O
,	O
java.util.ArrayDeque	O
,	O
and	O
java.util.PriorityQueue	O
.	O
</s>
<s>
LinkedList	O
,	O
of	O
course	O
,	O
also	O
implements	B-Language
the	O
List	O
interface	O
and	O
can	O
also	O
be	O
used	O
as	O
one	O
.	O
</s>
<s>
ArrayDeque	O
implements	B-Language
the	O
queue	O
as	O
an	O
array	O
.	O
</s>
<s>
Both	O
LinkedList	O
and	O
ArrayDeque	O
also	O
implement	O
the	O
java.util.Deque	O
interface	O
,	O
giving	O
it	O
more	O
flexibility	O
.	O
</s>
<s>
java.util.Queue	O
can	O
be	O
used	O
more	O
flexibly	O
with	O
its	O
subinterface	O
,	O
java.util.concurrent.BlockingQueue	O
.	O
</s>
<s>
java.util.PriorityQueue	O
implements	B-Language
java.util.Queue	O
,	O
but	O
also	O
alters	O
it	O
.	O
</s>
<s>
The	O
java.util.Queue	O
interface	O
is	O
expanded	O
by	O
the	O
java.util.Deque	O
subinterface	O
.	O
</s>
<s>
The	O
Deque	O
interface	O
is	O
implemented	O
by	O
java.util.ArrayDeque	O
and	O
java.util.LinkedList	O
.	O
</s>
<s>
The	O
java.util.concurrent.BlockingDeque	O
interface	O
works	O
similarly	O
to	O
java.util.concurrent.BlockingQueue	O
.	O
</s>
<s>
Java	B-Language
's	O
java.util.Set	O
interface	O
defines	O
the	O
set	O
.	O
</s>
<s>
Set	O
is	O
implemented	O
by	O
java.util.HashSet	O
,	O
java.util.LinkedHashSet	O
,	O
and	O
java.util.TreeSet	O
.	O
</s>
<s>
HashSet	O
uses	O
a	O
hash	B-Algorithm
table	I-Algorithm
.	O
</s>
<s>
More	O
specifically	O
,	O
it	O
uses	O
a	O
java.util.HashMap	O
to	O
store	O
the	O
hashes	O
and	O
elements	O
and	O
to	O
prevent	O
duplicates	O
.	O
</s>
<s>
java.util.LinkedHashSet	O
extends	O
this	O
by	O
creating	O
a	O
doubly	B-Data_Structure
linked	I-Data_Structure
list	I-Data_Structure
that	O
links	O
all	O
of	O
the	O
elements	O
by	O
their	O
insertion	O
order	O
.	O
</s>
<s>
java.util.TreeSet	O
uses	O
a	O
red	O
–	O
black	O
tree	O
implemented	O
by	O
a	O
java.util.TreeMap	O
.	O
</s>
<s>
Additionally	O
,	O
it	O
allows	O
TreeSet	O
to	O
implement	O
java.util.SortedSet	O
.	O
</s>
<s>
The	O
java.util.Set	O
interface	O
is	O
extended	O
by	O
the	O
java.util.SortedSet	O
interface	O
.	O
</s>
<s>
The	O
SortedSet	O
interface	O
is	O
implemented	O
by	O
java.util.TreeSet	O
.	O
</s>
<s>
java.util.SortedSet	O
is	O
extended	O
further	O
via	O
the	O
java.util.NavigableSet	O
interface	O
.	O
</s>
<s>
As	O
with	O
SortedSet	O
,	O
java.util.TreeSet	O
implements	B-Language
NavigableSet	O
.	O
</s>
<s>
Maps	O
are	O
defined	O
by	O
the	O
java.util.Map	O
interface	O
in	O
Java	B-Language
.	O
</s>
<s>
Maps	O
are	O
simple	O
data	B-General_Concept
structures	I-General_Concept
that	O
associate	O
a	O
key	O
with	O
an	O
element	O
.	O
</s>
<s>
Maps	O
are	O
implemented	O
by	O
java.util.HashMap	O
,	O
java.util.LinkedHashMap	O
,	O
and	O
java.util.TreeMap	O
.	O
</s>
<s>
HashMap	B-Algorithm
uses	O
a	O
hash	B-Algorithm
table	I-Algorithm
.	O
</s>
<s>
LinkedHashMap	O
extends	O
this	O
by	O
creating	O
a	O
doubly	B-Data_Structure
linked	I-Data_Structure
list	I-Data_Structure
between	O
the	O
elements	O
,	O
allowing	O
them	O
to	O
be	O
accessed	O
in	O
the	O
order	O
in	O
which	O
they	O
were	O
inserted	O
into	O
the	O
map	O
.	O
</s>
<s>
TreeMap	O
,	O
in	O
contrast	O
to	O
HashMap	B-Algorithm
and	O
LinkedHashMap	O
,	O
uses	O
a	O
red	O
–	O
black	O
tree	O
.	O
</s>
<s>
The	O
java.util.Map	O
interface	O
is	O
extended	O
by	O
its	O
subinterface	O
,	O
java.util.SortedMap	O
.	O
</s>
<s>
SortedMap	O
is	O
implemented	O
by	O
java.util.TreeMap	O
.	O
</s>
<s>
The	O
java.util.NavigableMap	O
interface	O
extends	O
java.util.SortedMap	O
in	O
various	O
ways	O
.	O
</s>
<s>
It	O
's	O
implemented	O
by	O
java.util.TreeMap	O
.	O
</s>
<s>
Java	B-Language
collections	I-Language
framework	I-Language
is	O
extended	O
by	O
the	O
Apache	B-Language
Commons	I-Language
Collections	O
library	B-Library
,	O
which	O
adds	O
collection	B-Application
types	O
such	O
as	O
a	O
bag	O
and	O
bidirectional	O
map	O
,	O
as	O
well	O
as	O
utilities	O
for	O
creating	O
unions	O
and	O
intersections	O
.	O
</s>
<s>
Google	O
has	O
released	O
its	O
own	O
collections	O
libraries	O
as	O
part	O
of	O
the	O
guava	B-Language
libraries	I-Language
.	O
</s>
