| introinterfaces collection |
Set is a special kind of Collection, and a
SortedSet is a special kind of Set, and so forth.
Note also that the hierarchy consists of two distinct trees: a
Map is not a true Collection.
To keep the number of core collection interfaces manageable, the JDK
doesn't provide separate interfaces for each variant of each collection type.
(Among the possible variants are immutable, fixed-size, and append-only.)
Instead, the modification operations in each interface are designated
optional: a given implementation may not support some of these
operations. If an unsupported operation is invoked, a collection throws an
UnsupportedOperationExceptionapiIcon (in the API reference documentation)
. Implementations are responsible for documenting which of the optional
operations they support. All of the JDK's general purpose implementations
support all of the optional operations.
The four sections that follow teach you how to use each of the four basic core collection interfaces. In particular, they describe the idioms that allow you to use these interfaces effectively.
Collection
represents a group of objects, known as its elements. Some
Collection implementations allow duplicate elements and others do
not. Some are ordered and others unordered. The JDK doesn't provide any
direct implementations of this interface: It provides implementations of
more specific subinterfaces like Set and List.
This interface is the least common denominator that all collections
implement. Collection is used to pass collections around and manipulate them when
maximum generality is desired.
List generally has
precise control over where in the List each element is inserted.
The user can access elements by their integer index (position). If you've
used
VectorapiIcon (in the API reference documentation), you're already familiar with the general flavor of List.
Map.
The last two core collection interfaces (SortedSet and
SortedMap) are merely sorted versions of Set and
Map. In order to understand these interfaces, you have to know
how order is maintained among objects. Even if you don't plan to use
SortedSet or SortedMap, read the
following section if you plan to sort Lists.
Now that you know all about object ordering, here are the last two core collection interfaces:
SortedSet is a Set that maintains its elements
in ascending order. Several additional operations are provided to take
advantage of the ordering. The SortedSet interface is used for
things like word lists and membership rolls.
Map that maintains its mappings in ascending key order. It
is the Map analogue of SortedSet. The
SortedMap interface is used for apps like dictionaries and
telephone directories.
| introinterfaces collection |
Bhopal news
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102