-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrya2D.java
More file actions
47 lines (37 loc) · 1.11 KB
/
Copy pathArrya2D.java
File metadata and controls
47 lines (37 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
public class Arrya2D {
public static void main(String[] args) {
int[][] arr = new int[3][3];
arr[0][0] = 1;
arr[0][1] = 1232;
arr[1][1] = 11;
arr[2][2] = 12;
// System.out.println(arr[1][1]);
// System.out.println(arr[0][1]);
int[][] newArr = {{1,2,3},{3,4,5},{4,5,7}};
int[][] newArr1 = {{1,2,3},{3,4},{4,5,7}};
System.out.println(newArr.length);
System.out.println(newArr[0].length);
System.out.println(newArr1.length);
//Traversal of 2D Array
int i =0;
while(i < newArr.length){
int j = 0;
while(j < newArr[i].length){
System.out.print(newArr[i][j]+" ");
j++;
}
System.out.println();
i++;
}
int i1 =0;
while(i1 < newArr1.length){
int j1 = 0;
while(j1 < newArr1[i1].length){
System.out.print(newArr1[i1][j1]+" ");
j1++;
}
System.out.println();
i1++;
}
}
}