title: ArrayList input java
body: <p>Im looking at the problem:</p>
  
  <blockquote>
    <p>Write a program which reads a sequence of integers and displays them in ascending order.</p>
  </blockquote>
  
  <p>Im creating an ArrayList (which I am new to) and I want to populate with integers input from the command line. With an array I could use a for loop with</p>
  
  <pre><code> for (int i =0; i &lt; array.length; i++) {
        array[i] = scanner.nextInt();
  </code></pre>
  
  <p>but with an ArrayList of unbounded size Im not sure how to process the input?</p>
  
  <p>EDIT:</p>
  
  <pre><code>class SortNumbers {
  
  public static void main(String[] args) {
  
  List numbers = new ArrayList();
  Scanner scanner = new Scanner(System.in);
  System.out.println("Enter some numbers.");
  
  while (scanner.hasNextInt()) {
  int i = scanner.nextInt();
  numbers.add(i);
      }
    }
  }
  </code></pre>