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
15 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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
99 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,020 points
24 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,590 points
41 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,820 points
51 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,820 points
42 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
49 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,360 points

edited Nov 6, 2018 by Omkar 4,529 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,030 points
1,214 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
41 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,820 points
54 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.