Professional Documents
Culture Documents
Arrays: Reference: Java Programming Fifth Edition by Joyce Farrell
Arrays: Reference: Java Programming Fifth Edition by Joyce Farrell
Objectives
Subscript
Integer contained within square brackets
Indicates one of arrays variables or elements
Initializing an Array
Variable with reference type
Such as array
Holds memory address where value stored
Array names
Represent computer memory addresses
Contain references
10
11
12
13
14
15
16
17
18
Two-dimensional arrays
19
20
21
22
23
24
You Do It
Creating and populating an array
Initializing an array
Using a for loop to access array elements
25
Dont Do It
Dont forget that the lowest array subscript is 0
Dont forget that the highest array subscript is one
less than the length
Dont forget that length is an array property and not
a method
Dont forget that array names are references
Dont forget that the first subscript used with a twodimensional array represents the row, and that the
second subscript represents the column
26
Summary
Array
Named list of data items
All have same type
Array names
Represent computer memory addresses
length field
Contains number of elements in array
Two-dimensional arrays
Both rows and columns
27