-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTwoDArrayDemo.java
More file actions
27 lines (26 loc) · 911 Bytes
/
Copy pathTwoDArrayDemo.java
File metadata and controls
27 lines (26 loc) · 911 Bytes
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
//wajp to demonstrate 3d array
import java.util.Scanner;
class TwoDArrayDemo {
public static void main(String[] args) {
int a[][][]=new int[3][3][3];
Scanner sc = new Scanner(System.in);
System.out.println("Enter array element 3x3x3: ");
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[i].length; j++) {
for (int k = 0; k < a[i][j].length; k++) {
a[i][j][k]=sc.nextInt();
}
}
}
System.out.println("Array element 3x3x3: ");
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[i].length; j++) {
for (int k = 0; k < a[i][j].length; k++) {
System.out.print(a[i][j][k] +" ");
}
System.out.println();
}
System.out.println("-----");
}
}
}