title: creating an array from a list of space separated integers
body: <p>I am trying to make a java program which can accept a list of numbers, each separated by a whitespace (Ex: 1 2 3 5 69 3124124 etc...) which then puts these numbers into an array and checks for duplicates. The whole thing works fine except for this method which is giving me trouble:</p>
  
  <pre><code>public static List returnArray(){
  System.out.println("type numbers here: ");
      while(sc.hasNextInt()){
          list.add(sc.nextInt());
      }
      return list;
  </code></pre>
  
  <p>"sc" is the arraylist</p>
  
  <p>It works fine except the only way for the program to understand it's finished being given input is for me to add a letter or something to the end, so an input of 1 2 3 doesn't do anything but an input of 1 2 3 r results in [1 2 3]. Any ideas how to write this so that it will know to stop taking input after more than one blank space and not need some other character at the end?</p>