0% found this document useful (0 votes)
34 views1 page

3d Array

The Java program initializes a 3D array of size 10x10x10 and prompts the user to input dimensions i, j, and k. It then populates the array with the product of its indices and prints the resulting values. The program demonstrates basic array manipulation and user input handling in Java.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views1 page

3d Array

The Java program initializes a 3D array of size 10x10x10 and prompts the user to input dimensions i, j, and k. It then populates the array with the product of its indices and prints the resulting values. The program demonstrates basic array manipulation and user input handling in Java.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

package java3darray;

import java.util.Scanner;
public class Java3DArray {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int threeDArray[][][] = new int[10][10][10];
int i = 0, j = 0, k = 0;

System.out.print("Enter the value of i : ");


i = input.nextInt();

System.out.print("Enter the value of j : ");


j = input.nextInt();

System.out.print("Enter the value of k : ");


k = input.nextInt();

System.out.println("");

for(int m=0; m < i; m++)


for(int n=0; n < j; n++)
for(int p=0; p < k; p++)
threeDArray[m][n][p] = m * n * p;

for(int m=0; m < i; m++) {


for(int n=0; n < j; n++) {
for(int p=0; p < k; p++)
System.out.print(threeDArray[m][n][p] + " ");
System.out.println();
}
System.out.println();
}
}
}

You might also like