I would like to use input an array of arraylist, where the first input is the number of arrays of arraylist and the next line represents the input for each array. Please let me know where am going wrong. Please find below the code for the same:
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int a = input.nextInt();
ArrayList[] al = new ArrayList[a];
for( int i =0; i<a; i++){
while(input.hasNextLine())
{
al[i].add(input.nextInt());
}
}
System.out.print("result is"+al[0]);
}