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,150 points
38 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,190 points
588 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,050 points
57 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 parth295
• 4,640 points
78 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,880 points
152 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,880 points
90 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 in Java by monica jesvina
83 views
+5 votes
3 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,380 points

edited Nov 6, 2018 by Omkar 10,223 views
0 votes
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,110 points
2,288 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
86 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,880 points
108 views