How to give user input for array of arraylist? : <p>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:</p>

<pre><code>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&lt;a; i++){            
        while(input.hasNextLine())
            {
              al[i].add(input.nextInt());
            }
    }
    System.out.print("result is"+al[0]);        
}
</code></pre>
