- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaccessarray.java
More file actions
Latest commit
16 lines (14 loc) · 518 Bytes
/
Copy pathaccessarray.java
File metadata and controls
16 lines (14 loc) · 518 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//this program tells you the array index
publicclassaccessarray{
publicstaticvoidmain(String[] args) {
// create an array
int[] age = {12, 4, 5, 2, 5};
// access each array elements
System.out.println("Accessing Elements of Array:");
System.out.println("First Element: " + age[0]);
System.out.println("Second Element: " + age[1]);
System.out.println("Third Element: " + age[2]);
System.out.println("Fourth Element: " + age[3]);
System.out.println("Fifth Element: " + age[4]);
}
}