title: How to store input values in an array by using Scanner in Java
body: <p>Hi I am new to Java and I was experimenting with the Scanner class.
  I am trying to figure out a small problem in which I want to enter two inputs such as:
  4 5 6 and 8 9 0.
  I want to store 4,5,6 in one array and 8,9,0 in another array and then print these arrays.
  But I am unable to do so. 
  I wrote the following code :</p>
  
  <pre><code>public class scanner {
  
  public static void main(String[] args) {
  
      int[] array = new int[3];
      int[] array2 = new int[3];
      Scanner scan = new Scanner(System.in);
  
      int i = 0;
      while(scan.hasNextInt()){
          array[i] = scan.nextInt();
          i++;
          if(i == 3){
              break;
          }
      }
  
      i = 0;
      while(scan.hasNextInt()){
          array2[i] = scan.nextInt();
          i++;
          if(i == 3){
              break;
          }
      }
  
      for(int j  = 0; j &lt; array.length; j++){
          System.out.println(array[j]);
      }
  
      for(int j  = 0; j &lt; array2.length; j++){
          System.out.println(array2[j]);
      }
  }
  
  }
  </code></pre>
  
  <p>But this doesn't takes the input 4 5 6 in one single line. 
  I want to enter 4 5 6 in one line so that all the three digits are stored in the array.
  Can someone please help me. I assume I should use delimiter to remove the white space but I am not sure how to go about it. </p>