ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

Java - Example of Two Dimensional Arrays.


IncludeHelp 02 July 2016

In this code snippet we will learn, how to declare and print multi dimensional (two dimensional) array in java.

Java Code Snippet - Example of Multi (Two) Dimensional Arrays

//Java - Example of Two Dimensional Array.
 
class ExampleTwoDArray
{
	public static void main(String args[])
	{
		//declaration of two dimensional array
		int twoDA[][]={ {10,20,30}, {40,50,60}, {70,80,90} };
		
		//print two dimensional array
		for(int row=0; row<twoDA.length; row++){
			for(int col=0; col<twoDA[row].length; col++){
				System.out.print(twoDA[row][col]+"  ");
			}
			System.out.println(); //print new line after onw row
		}
					
	}
}
    
    10  20  30
    40  50  60
    70  80  90

ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.