DSweek4 Array
DSweek4 Array
Arrays
Objectives
At the end of this lesson the student shld., be
able to:
1. Recognize the use of Arrays
2. Identify the different types of array
3. State the difference of one dimensional
arrays with multi-dimensional arrays in terms of
declaration, initialization and usage process
Arrays
• Arrays are objects that help us organize large
amounts of information
Outline
Declaring and Using Arrays
Arrays of Objects
Two-Dimensional Arrays
Arrays
• An array is an ordered list of values
The entire array Each value has a numeric index
has a single name
0 1 2 3 4 5 6 7 8 9
scores 79 87 94 82 67 98 87 81 74 91
scores[first] = scores[first] + 2;
scores 79
87
94
82
67
98
87
81
74
91
Declaring Arrays
• The scores array could be declared as
follows:
int[] scores = new int[10];
boolean[] flags;
flags = new boolean[20];
• Examples:
int[] units = {147, 323, 89, 933, 540,
269, 97, 114, 298, 476};
words -
-
-
-
-
System.out.println (words[0]);
Arrays of Objects
Length = 6
Length = 4
raggedArray
Length = 5
Length = 5 Length = 2