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.08 KB
/
ArrayDemo.java
File metadata and controls
34 lines (31 loc) · 1.08 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 longs and allocates memory for 10 longs
long[] longArray = new long[10];
// initialize first element
longArray[0] = 10000L;
// initialize second element
longArray[1] = 30000L;
// and so forth
longArray[2] = 35000L;
longArray[3] = 40000L;
longArray[4] = 45000L;
longArray[5] = 42000L;
longArray[6] = 50000L;
longArray[7] = 60000L;
longArray[8] = 90000L;
longArray[9] = 80000L;
System.out.println("Element at index 0: " + longArray[0]);
System.out.println("Element at index 1: " + longArray[1]);
System.out.println("Element at index 2: " + longArray[2]);
System.out.println("Element at index 3: " + longArray[3]);
System.out.println("Element at index 4: " + longArray[4]);
System.out.println("Element at index 5: " + longArray[5]);
System.out.println("Element at index 6: " + longArray[6]);
System.out.println("Element at index 7: " + longArray[7]);
System.out.println("Element at index 8: " + longArray[8]);
System.out.println("Element at index 9: " + longArray[9]);
}
}