[an error occurred while processing this directive]

Multidimensional Array Java

                          

Array is a collection of a same data type. When we have the data of the same type and same scope then its better to store it in an array. We use mostly two types of arrays that is simple array and multi dimensional array.  

In the example given below we have used two dimensional array. A two dimensional array can be thought as a grid of rows and columns. The first array will reflect to a row and the second one is column. In the example we have written it as int TwoArray[ ][ ]  = new int [7 ][12 ];.  In this example we will have 7 rows and 12 columns 

The output of the program is given below:

<HTML>
  <HEAD>
    <TITLE>Multidimensional Arrays in Jsp</TITLE>
  </HEAD>
  <BODY>
    <FONT SIZE="6" COLOR="#990000">Multidimensional Arrays in Jsp</FONT>
    <%
        int TwoArray[][] = new int[7][12];
		int a,b, c = 0;
		for(a=0; a < 4;a++){
			
			for(b=0; b<5;b++){
				TwoArray[a][b] =c;
				c++;
			}
		
		}
			for(a=0;a<4;a++){
				for(b=0;b<5;b++){
					out.println(TwoArray[a][b] + " ");
				}
				out.println("<br>");
				
				}
     %>
  </BODY>
</HTML>

Output of the Program:

Download this example.

                          

[an error occurred while processing this directive]