title: Trying to Get Integer Separated by Space in Java
body: <p>I am trying to enter integers separated by a space and then trying to retrieve them. As simple as that, but I am unable to do that.</p>
  
  <p>So what I am trying to do is, First asking how many numbers a user would like to enter, he/she would enter the number and then would enter that amount of numbers with space in the middle.</p>
  
  <p>After a user entered the numbers separated with space, I would just want to print them back.</p>
  
  <h2>Proposed Output</h2>
  
  <pre><code>How many numbers do you want to enter?
  
  5
  
  Please enter 5 integers seperated by a space
  
  1 2 3 4 5
  
  You entered:-
  
  1
  2
  3
  4
  5
  </code></pre>
  
  <h2>This is what I did:-</h2>
  
  <pre><code>int amountofnumbers;
  
  Scanner myinput = new Scanner(System.in);
  Scanner myinput2 = new Scanner(System.in);
  
  System.out.println("How many numbers do you want to enter?");
  int amountofnumbers = myinput.nextInt();
  
  
  System.out.println("Please enter" + amountofnumbers + "integers seperated by a space");
  actualnumbers = myinput2.nextInt();
  
  System.out.println("You entered:- ");
  for (int i = 1; i &lt;= amountofnumbers ; i++) 
  { 
      System.out.println(actualnumbers);
  }
  </code></pre>
  
  <h2>Result</h2>
  
  <p>At the moment, it shows</p>
  
  <pre><code>1
  1
  1
  1
  1
  </code></pre>