Java Reference
In-Depth Information
SR 7.35
The containment hierarchy tree for the LeftRight application GUI pre-
sented in Chapter 5 is:
JFrame
JPanel
JPanel
JPanel
JButton
JButton
Chapter 8 Arrays
8.1 Array Elements
SR 8.1
An array is an object that stores a list of values. The entire list can be
referenced by its name, and each element in the list can be referenced
individually based on its position in the array.
SR 8.2
Each element in an array can be referenced by its numeric position,
called an index, in the array. In Java, all array indexes begin at zero.
Square brackets are used to specify the index. For example, nums[5]
refers to the sixth element in the array called nums .
SR 8.3
a. 61, b. 139, c. 73, d. 79, e. 74, f. 11
8.2 Declaring and Using Arrays
SR 8.4
An array's element type is the type of values that the array can hold.
All values in a particular array have the same type, or are at least of
compatible types. So we might have an array of integers, or an array of
boolean values, or an array of Dog objects, etc.
SR 8.5
Arrays are objects. Therefore, as with all objects, to create an array we
first create a reference to the array (its name). We then instantiate the
array itself, which reserves memory space to store the array elements.
The only difference between a regular object instantiation and an array
instantiation is the bracket syntax.
SR 8.6
int [] ages = new int [100] ;
SR 8.7
int [] faceCounts = new int [6] ;
Search WWH ::




Custom Search