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
772 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,174 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,120 points
963 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,630 points
877 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,910 points
11,578 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,910 points
840 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
978 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 79,495 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
7,952 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
646 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,910 points
4,770 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