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
37 lines (33 loc) · 1.13 KB
/
Copy pathArrayDemo.java
File metadata and controls
37 lines (33 loc) · 1.13 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
35
36
37
class ArrayDemo
{
public static void main(String[] args)
{
// declares an array of doubles
double[] doubleArray;
// allocates memory for 10 doubles
doubleArray = new double[10];
// initialize first element
doubleArray[0] = 10.2;
// initialize second element
doubleArray[1] = 20.3;
// and so forth
doubleArray[2] = 30.8;
doubleArray[3] = 50.8;
doubleArray[4] = 90.9;
doubleArray[5] = 100.8;
doubleArray[6] = 23.5;
doubleArray[7] = 99.9;
doubleArray[8] = 88.4;
doubleArray[9] = 97.8;
System.out.println("Element at index 0: " + doubleArray[0]);
System.out.println("Element at index 1: " + doubleArray[1]);
System.out.println("Element at index 2: " + doubleArray[2]);
System.out.println("Element at index 3: " + doubleArray[3]);
System.out.println("Element at index 4: " + doubleArray[4]);
System.out.println("Element at index 5: " + doubleArray[5]);
System.out.println("Element at index 6: " + doubleArray[6]);
System.out.println("Element at index 7: " + doubleArray[7]);
System.out.println("Element at index 8: " + doubleArray[8]);
System.out.println("Element at index 9: " + doubleArray[9]);
}
}