We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ea56de5 commit 9e71b6cCopy full SHA for 9e71b6c
Creating and Initializing 1D,2D Arrays
@@ -17,6 +17,14 @@ public static void main(String[] args) {
17
// Initialzing 2d array. Doing initialization and creation in the same step, does not require 'new' operator.
18
String[][] TwoDArray = {{"hello","world"},{"hi","bye"},{"me","tu"},{"aapli","aapla"}}; // 4*2 array
19
int[][] intTwoArray = {{1,2,3},{4,5,6},{8,9,10},{11,12,13},{14,15,16}}; // 3*5 array
20
+//Use 2D array
21
+ int[][] maze = new int[6][6];
22
+ maze[0] = new int[] { 1, 1, 0, 0, 0, 0 };
23
+ maze[1] = new int[] { 0, 1, 0, 0, 0, 0 };
24
+ maze[2] = new int[] { 0, 1, 0, 1, 1, 1 };
25
+ maze[3] = new int[] { 1, 1, 1, 1, 0, 1 };
26
+ maze[4] = new int[] { 0, 1, 0, 0, 0, 1 };
27
+ maze[5] = new int[] { 0, 1, 0, 0, 0, 1 };
28
29
// Accessing number of rows and columns in multidimentional arrays
30
int rows = TwoDArray.length; // Gives number of rows
0 commit comments