java (52)
java (52)
class Main {
public static void main(String[] args){
int[][] arr = { { 1, 2 },
{ 3, 4 } };
Output
a[1][1] : 4
System.out.println();
}
scn.close();
}
}
Input:
Enter number of rows: 3
Enter number of columns: 3
Output:
1 2 3
2 4 6
3 6 9
Three – Dimensional Array (3D-Array)
3D-Array is a complex form of a multidimensional array. A 3D-array can be seen as
an array of 2D array for easier understanding.
Representation of 3D Array in Tabular Format
A three-dimensional array can be seen as a table of arrays with ‘x’ rows and ‘y’
columns where the row number ranges from 0 to (x-1) and column number ranges
from 0 to (y-1). A three – dimensional array with 3 array containing 3 rows and 3
columns is shown below:
Example 1:
// Java Program to Demonstrate
// Three Dimensional Array
import java.io.*;
class Main {
public static void main(String[] args){
Output
arr[0][0][0] = 1
arr[0][0][1] = 2
arr[0][1][0] = 3
arr[0][1][1] = 4
arr[1][0][0] = 5
arr[1][0][1] = 6
arr[1][1][0] = 7
arr[1][1][1] = 8
Example 2:
// Java Program to Implement
// Three Dimensional Array
import java.io.*;
class Main {
public static void main(String[] args){
int it=1;