-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiDimensional.java
More file actions
76 lines (50 loc) · 1.46 KB
/
MultiDimensional.java
File metadata and controls
76 lines (50 loc) · 1.46 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package com.yashas;
import java.util.Scanner;
//import java.util.Arrays;
public class MultiDimensional {
public static void main(String[] args){
/*
1 2 3
4 5 6
7 8 9
*/
// int [][] arr=new int[3][]; // 1st bracket is for row and 2nd is for column
// here row should be mandatory mentioned
//or
/*
int [][] array ={
{1,2,3},
{3,4,5},
{5,6,7},
};*/
// int [][] array ={
// {1,2,3},
// {3,4},
// {5,6,7,9},
//};
// input
Scanner in=new Scanner(System.in);
int [][] arry= new int[3][3];
for (int row=0;row< arry.length;row++){
for(int col=0;col<arry[row].length;col++){
arry[row][col]=in.nextInt();
}
}
// output 1
/*for (int row=0;row< arry.length;row++){
for(int col=0;col<arry[row].length;col++){
System.out.print(arry[row][col]+" ");
}
System.out.println();
}*/
// output 2
/* for(int row =0; row<arry.length;row++){
System.out.println(Arrays.toString(arry[row]));
}*/
//output 3
// for(int[] a:arry){
// System.out.println(Arrays.toString(a));
// }
System.out.println(arry[2][1]);
}
}