Java Reference
In-Depth Information
Asaresult,
i1 < i2
isconvertedto
i1.intValue() < i2.intValue()
and
i1+i2
is converted to
i1.intValue()+i2.intValue()
.
Caution
Don'tassumethatautoboxingandunboxingareusedinthecontextofthe
==
and
!=
operators.
List
A
list
is an ordered collection, which is also known as a
sequence
. Elements can be
stored in and accessed from specific locations via integer indexes. Some of these ele-
mentsmaybeduplicatesornull(whenthelist'simplementationallowsnullelements).
Lists are described by the
List
interface, whose generic type is
List<E>
.
List
extends
Collection
and redeclares its inherited methods, partly for con-
venience. It also redeclares
iterator()
,
add()
,
remove()
,
equals()
, and
hashCode()
to place extra conditions on their contracts. For example,
List
's con-
tract for
add()
specifies that it appends an element to the end of the list, rather than
adding the element to the collection.
List
also declares
Table 5-2
's list-specific methods.