Code:
import java.io.*;
import java.util.*;
class Arr
{
public static void main( String args[] )
{
int a[][][] = new int[2][4][3];
Scanner scan = new Scanner(new InputStreamReader(System.in) );
System.out.println("\n\n Enter 24 elements: ");
for(int i = 0; i<2 ; i++ )
{
for(int j = 0; j<4 ; j++)
{
for(int k= 0; k<3 ; k++)
{
System.out.print("Enter for a["+i+"]["+j+"]["+k+"] = ");
a[i][j][k] = scan.nextInt();
}
System.out.println("\n");
}
System.out.println("\n");
}
System.out.println("\n\n Displaying array elements: ");
for(int i = 0; i<2 ; i++ )
{
for(int j = 0; j<4 ; j++)
{
System.out.println("\n");
for(int k= 0; k<3 ; k++)
{
System.out.print(a[i][j][k]+" ");
}
}
System.out.println("\n");
}
}
}
Ouput:
import java.io.*;
import java.util.*;
class Arr
{
public static void main( String args[] )
{
int a[][][] = new int[2][4][3];
Scanner scan = new Scanner(new InputStreamReader(System.in) );
System.out.println("\n\n Enter 24 elements: ");
for(int i = 0; i<2 ; i++ )
{
for(int j = 0; j<4 ; j++)
{
for(int k= 0; k<3 ; k++)
{
System.out.print("Enter for a["+i+"]["+j+"]["+k+"] = ");
a[i][j][k] = scan.nextInt();
}
System.out.println("\n");
}
System.out.println("\n");
}
System.out.println("\n\n Displaying array elements: ");
for(int i = 0; i<2 ; i++ )
{
for(int j = 0; j<4 ; j++)
{
System.out.println("\n");
for(int k= 0; k<3 ; k++)
{
System.out.print(a[i][j][k]+" ");
}
}
System.out.println("\n");
}
}
}