- 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
How to create and populate two-dimension Java 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 −
Example
public class Creating2DArray { public static void main(String args[]) { int[][] myArray = new int[3][3]; myArray[0][0] = 21; myArray[0][1] = 22; myArray[0][2] = 23; myArray[1][0] = 24; myArray[1][1] = 25; myArray[1][2] = 26; myArray[2][0] = 27; myArray[2][1] = 28; myArray[2][2] = 29; for(int i=0; i<myArray.length; i++ ) { for(int j=0;j<myArray.length; j++) { System.out.println(myArray[i][j]); } } } }
Output
21 22 23 24 25 26 27 28 29
- Related Articles
- How to create and populate Java array of Hash tables?
- How to create JTable from two dimensional array in Java?
- How to populate a 2d array with random alphabetic values from a range in Java?
- Java Program to create DefaultTableModel from two dimensional array
- How to populate an array one value at a time by taking input from user in Java?
- How to create an Array in Java?
- Algorithm to dynamically populate JavaScript array with zeros before and after values
- How to declare, create, initialize and access an array in Java?
- How to create a generic array in java?
- How to create array of strings in Java?
- How to create and write JSON array to a file in java?
- How to create a two dimensional array in JavaScript?
- How to create a two-dimensional array in TypeScript?
- How to populate a Map using a lambda expression in Java?\n
- Java program to create a sorted merged array of two unsorted arrays

Advertisements