- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava_Arraylist.java
More file actions
Latest commit
46 lines (39 loc) · 1 KB
/
Copy pathJava_Arraylist.java
File metadata and controls
46 lines (39 loc) · 1 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
importjava.io.*;
importjava.util.*;
importjava.text.*;
importjava.math.*;
importjava.util.regex.*;
publicclassJava_Arraylist {
publicstaticvoidmain(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scannerscan=newScanner(System.in);
inttotal=scan.nextInt();
ArrayList<ArrayList<Integer>> mainlist=newArrayList<>();
for(inti=0;i<total;i++)
{
intsize=scan.nextInt();
ArrayList<Integer> list=newArrayList();
for(intj=0;j<size;j++)
{
intitem=scan.nextInt();
list.add(item);
}
mainlist.add(list);
}
inttotalprint=scan.nextInt();
for(intk=0;k<totalprint;k++)
{
introw=scan.nextInt();
intcol=scan.nextInt();
try
{
System.out.println(mainlist.get(row-1).get(col-1));
}
catch(Exceptione)
{
System.out.println("ERROR!");
}
}
scan.close();
}
}