We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
List<List<Integer>> listOfArray = new ArrayList<>();
Scanner s= new Scanner(System.in);
int n =s.nextInt();
for(int i=0;i<n;i++){
int d=s.nextInt();
List<Integer> listf = new ArrayList<Integer>() ;
for(int j=0;j<d;j++){
listf.add(s.nextInt());
}
listOfArray.add(listf);
}
// System.out.println(listOfArray);
int q =s.nextInt();
for(int i=0;i<q;i++){
int x= s.nextInt();
int y =s.nextInt();
try{
System.out.println( listOfArray.get(x-1).get(y-1));
}
catch(Exception ex){
System.out.println("ERROR!");
}
}
s.close();
}
Java Arraylist
You are viewing a single comment's thread. Return to all comments →
import java.io.; import java.util.;
public class Solution {
}