Java Reference
In-Depth Information
CHAPTER
6
S
INGLE
-D
IMENSIONAL
A
RRAYS
Objectives
To describe why arrays are necessary in programming (§6.1).
■
To declare array reference variables and create arrays (§§6.2.1-6.2.2).
■
To obtain array size using
arrayRefVar.length
and know default values
in an array (§6.2.3).
■
To access array elements using indexed variables (§6.2.4).
■
To declare, create, and initialize an array using an array initializer (§6.2.5).
■
To program common array operations (displaying arrays, summing all
elements, finding the minimum and maximum elements, random shuffling,
and shifting elements) (§6.2.6).
■
To simplify programming using the for-each loops (§6.2.7).
■
To apply arrays in application development (
LottoNumbers
,
DeckOfCards
) (§§6.3-6.4).
■
To copy contents from one array to another (§6.5).
■
To develop and invoke methods with array arguments and return values
(§§6.6-6.8).
■
To define a method with a variable-length argument list (§6.9).
■
To search elements using the linear (§6.10.1) or binary (§6.10.2) search
algorithm.
■
To sort an array using the selection sort approach (§6.11.1).
■
To sort an array using the insertion sort approach (§6.11.2).
■
To use the methods in the
java.util.Arrays
class (§6.12).
■