L6 Computer Programming 2 1
L6 Computer Programming 2 1
JAV
A
UI
java >
ARRAYS U
X
Lesson objectives:
use array declaration;
1
use arrays in a Java
understand accessing
4 program.
2 elements of an array;
understand
3 multidimensional
arrays; and
ARRAY
Example:
Int [ ] arrayNumbers;
String [ ] arrayNames;
char [ ] arrayLetters;
double [ ] arrayDouble;
float [ ] arrayValue;
int arrayNumbers [ ];
Initializing arrays
Below is the syntax for creating
an array of integers
indices
first index
0 1 2 3 4
10 120 30 80 100
Array length is 5
elements
Initializing arrays
An array uses indexing to store and retrieve its
elements. Each item in an array is called element.
Hence, if we want to display the 4th element of the
array, we write:
System.out.println(arrayNumbers [3]);
• The array index will always start with index of zero [0].
THANK
S!
Do you have any questions?
addyouremail@freepik.co
m +91 620 421 838
yourcompany.com