title: Reading an integer from the command prompt in Java using Scanner
body: <p>I can't figure out what I'm doing wrong here.</p>
  
  <p>My code:</p>
  
  <pre><code>import java.util.Scanner;
  
  public class test
    {
      public static void main(String args[])
        {
          Scanner input_scanner = new Scanner(System.in);
          System.out.printf("\nEnter number:");
  
          int num_shapes = input_scanner.nextInt();
  
          System.out.printf("\n%d", num_shapes);
        }
    }
  </code></pre>
  
  <p>Each time the program is run, I enter an integer, press the enter key, am taken to a new line, enter a new integer, and hit the enter key again.  The first integer is then displayed.</p>
  
  <p>How can I get it to display the first integer directly after it is entered, without having to enter a second integer?</p>
  
  <p>I've tried it with and without</p>
  
  <pre><code>    input_scanner.nextLine();
  </code></pre>
  
  <p>following the line containing 'nextInt()', but get the same thing either way.</p>
  
  <p>Any help in resolving this problem is greatly appreciated.</p>