A two dimensional array is implemented as an array of one dimensional arrays. The Two Dimensional Array is an array of arrays. We use a new operator to create a two dimensional arrays. For example:
Data_Type[][] Array_Name = new int[Row_Size][Column_Size];
Row_size is row elements an array can store. For instance, For example, Row_Size = 6, then the array will have six rows. Column_Size is the column elements an array can store. For example, Column_Size = 7, then the array will have seven columns. The two dimensional arrays can be declared and created in the same line of code. For intance,
int[][] Student_Marks = new int[2][3];
We can also create a two dimensional array and assign the elements to that array without stating the row and column size. For instance,
int[][] Employees = { {10, 20, 30}, {15, 25, 35}, {22, 44, 66}, {33, 55, 77} };
Comments
Leave a comment