forked from ramram43210/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayDemo.java
More file actions
34 lines (31 loc) · 1.07 KB
/
ArrayDemo.java
File metadata and controls
34 lines (31 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class ArrayDemo
{
public static void main(String[] args)
{
// declares an array of Strings and allocates memory for 10 Strings
String[] strArray = new String[10];
// initialize first element
strArray[0] = "Apple";
// initialize second element
strArray[1] = "Ball";
// and so forth
strArray[2] = "Car";
strArray[3] = "Dog";
strArray[4] = "Eagle";
strArray[5] = "Fox";
strArray[6] = "Girl";
strArray[7] = "Horse";
strArray[8] = "Ink";
strArray[9] = "Jack";
System.out.println("Element at index 0: " + strArray[0]);
System.out.println("Element at index 1: " + strArray[1]);
System.out.println("Element at index 2: " + strArray[2]);
System.out.println("Element at index 3: " + strArray[3]);
System.out.println("Element at index 4: " + strArray[4]);
System.out.println("Element at index 5: " + strArray[5]);
System.out.println("Element at index 6: " + strArray[6]);
System.out.println("Element at index 7: " + strArray[7]);
System.out.println("Element at index 8: " + strArray[8]);
System.out.println("Element at index 9: " + strArray[9]);
}
}