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



Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.