All Courses
Multidimensinal Array in Java

Multidimensional Array in Java

April 30th, 2019 Java

Multidimensional Array in Java

  • Array is a type of data types.
  • We are going for array to store multiple values to a single variable.
  • Where as in other data types like int,float,char etc. we can store only one value.
  • All the value in the array should be as same type. For example, if we diclare an array as int datatype we can store only integer values into it.
  • When array has arrays of values then it is called as multidimensional array.

Example:

int mulDim[][]= new int[4][5];

Example Program:

public class MultiDim {
public static void main(String[] args) {
int[][] multidimArray = { {1,2},{2,3}, {3,4} };
for(int i = 0 ; i < 3 ; i++){
for(int j = 0 ; j < 2; j++){
System.out.print(multidimArray[i][j] + " ");
}
}
}
}

Output:

1          2

2          3

3          4

Social Share:

0 responses on "Multidimensional Array in Java"

Leave a Message

Your email address will not be published. Required fields are marked *