title: Reading integers for a stack from user input
body: <p>I am trying to create a program that takes user input from a scanner and pushes it onto a stack and then pops off each element and prints it out. Here is my code thus far:</p>
  
  <pre><code>import java.util.*;
  
  public class NumberReverse {
  public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
  
      System.out.print("Enter numbers: ");
      int number = sc.nextInt();
  
      Stack&lt;Integer&gt; stack = new Stack&lt;Integer&gt;();
      stack.push(number);
  
      while (!(stack.isEmpty())) {
          System.out.println(stack.pop());
      }
  }
  }
  </code></pre>