- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is a Multidimensional array in Java?
In Java, a multi-dimensional array is nothing but an array of arrays.
2D array − A two-dimensional array in Java is represented as an array of one-dimensional arrays of the same type. Mostly, it is used to represent a table of values with rows and columns −
Int[][] myArray = {{10, 20, 30}, {11, 21, 31}, {12, 22, 32} }
In short, a two-dimensional array contains one-dimensional arrays of elements. It is represented by two indices where the first index denotes the position of the array and the second index represents the position of the element within that particular array −
Example
public class Tester { public static void main(String[] args) { int[][] multidimensionalArray = { {1,2},{2,3}, {3,4} }; for(int i = 0 ; i < 3 ; i++){ //row for(int j = 0 ; j < 2; j++){ System.out.print(multidimensionalArray[i][j] + " "); } System.out.println(); } } }
Output
1 2 2 3 3 4
Advertisements