title: Java ArrayList of ArrayList Scanner UserInput
body: <p>I am trying to store user input into ArrayList of ArrayList.  </p>
  
  <pre><code>ArrayList&lt;ArrayList&lt;Integer&gt;&gt; a = new ArrayList&lt;ArrayList&lt;Integer&gt;&gt;();
  </code></pre>
  
  <p>For example, storing it as <code>[[1,2,3],[4,5],[6,1,8]]</code><br>
  Below is my code,</p>
  
  <pre><code>    Scanner input = new Scanner(System.in);
      System.out.println("Enter a set of numbers:");
      String line = input.nextLine();
      String[] numbers = line.split(" +");
  
      ArrayList&lt;ArrayList&lt;Integer&gt;&gt; a = new ArrayList&lt;ArrayList&lt;Integer&gt;&gt;();
      ArrayList&lt;Integer&gt; a1 = new ArrayList&lt;Integer&gt;();
  
      for(int i=0; i&lt;numbers.length; i++) {
          a1.add(new Integer(numbers[i]));
  
      }
      a.add(a1);
  </code></pre>
  
  <p>But then when I types it in to terminal, it becomes <code>[[1,2,3,4,5,6,1,8]]</code>.<br>
  Thank you in advance!</p>