Java – Two dimensional arrays

Previous
Next

Two dimensional arrays:

  • One dimensional array is linear, the elements store side by side.
  • Two dimensional arrays are used to process elements in rows and columns.
  • We can declare a 2 dimensional array in different ways.
class Main
{
	public static void main(String[] args) 
	{
		int a[][];
		int[][] b;
		int[] c[];
	}
}

Memory allocation of 2 dimensional arrays:

  • We use nested for loop to process the elements of two dimensional array.
  • Outer loop represents number of rows.
  • Inner loop represents number of columns.
Previous
Next

Add Comment

Courses Enquiry Form