-
Notifications
You must be signed in to change notification settings - Fork 0
/
Arrays042.java
36 lines (28 loc) · 1.19 KB
/
Arrays042.java
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
public class Arrays042 {
public static void main(String[] args) {
int[] intArray1 = new int[10];
for (int index = 0; index < (intArray1.length); index++) {
System.out.printf("Element #" + (index + 1) + ": " + intArray1[index] + "\n");
}
System.out.println();
intArray1[4] = 50;
for (int index = 0; index < (intArray1.length); index++) {
System.out.printf("Element #" + (index + 1) + ": " + intArray1[index] + "\n");
}
System.out.println("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
double[] doubleArray1 = new double[10];
for (int index = 0; index < (doubleArray1.length); index++) {
System.out.printf("Element #" + (index + 1) + ": " + doubleArray1[index] + "\n");
}
System.out.println();
doubleArray1[4] = 150.0;
for (int index = 0; index < (doubleArray1.length); index++) {
System.out.printf("Element #" + (index + 1) + ": " + doubleArray1[index] + "\n");
}
System.out.println("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
int[] intArray2 = new int[]{1, 2, 3, 4};
for (int index = 0; index < (intArray2.length); index++) {
System.out.printf("Element #" + (index + 1) + ": " + intArray2[index] + "\n");
}
}
}