How to initialize multi-dimensional array in java

0 votes
I am new to java language. I don't know how initialize multi-dimeansional array. Please help?
Jun 6, 2018 in Java by Akrati
• 3,190 points
936 views

1 answer to this question.

0 votes

multidimensional array in Java is really an array within an array (and as more dimensions are added, the hall of mirrors continues)

You can refer below example for initializing multi-dimensional array:

class Array

{  

public static void main(String args[])

{  

int a[][]={{1,2,3},{2,4,5},{4,4,5}};  ​  // Declaring and initializing multi-dimenasional array

for(int i=0;i<3;i++)

{  

 for(int j=0;j<3;j++)

{  

System.out.print(arr[i][j]+" ");  

 }  

 System.out.println();  

}

}

}

answered Jun 6, 2018 by sophia
• 1,400 points

Related Questions In Java

+1 vote
3 answers

What is the syntax to declare and initialize an array in java?

You can use this method: String[] strs = ...READ MORE

answered Jul 25, 2018 in Java by samarth295
• 2,220 points
3,578 views
0 votes
2 answers

How to create a 2-D array in java?

int[][] multi = new int[5][]; multi[0] = new ...READ MORE

answered Jul 16, 2018 in Java by Daisy
• 8,140 points
1,544 views
0 votes
3 answers

How to sort an array in java?

import java.util.Arrays; public class Sort { ...READ MORE

answered Aug 24, 2018 in Java by Parth
• 4,640 points
1,210 views
0 votes
3 answers

How can I add new elements to an Array in Java

String[] source = new String[] { "a", ...READ MORE

answered Sep 19, 2018 in Java by Sushmita
• 6,920 points
13,192 views
0 votes
2 answers

How a static map can be initialized?

public class Test { ...READ MORE

answered Sep 12, 2018 in Java by Sushmita
• 6,920 points
1,080 views
0 votes
2 answers

How to initialize multi-dimensional array in java?

a multidimensional array can define an array ...READ MORE

answered Mar 18, 2019 in Java by monica jesvina
1,308 views
+5 votes
4 answers

How to execute a python file with few arguments in java?

You can use Java Runtime.exec() to run python script, ...READ MORE

answered Mar 27, 2018 in Java by DragonLord999
• 8,450 points

edited Nov 7, 2018 by Omkar 81,223 views
+1 vote
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,500 points
8,359 views
0 votes
1 answer

How to print java array in the simplest way?

String[] arr = new String[] {"John", "Mary", ...READ MORE

answered Apr 17, 2018 in Java by sophia
• 1,400 points
840 views
0 votes
2 answers

How an object array can be converted to string array in java?

System.arraycopy is the most efficient way, but ...READ MORE

answered Aug 8, 2018 in Java by Sushmita
• 6,920 points
5,656 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP