title: An unused declaration makes my program work Correctly?
body: <p>So I wrote this code and I wrote " int number = input.nextInt(); " in it as an experiment. The program does exactly what I want it to, but I don't understand why this works. The variable is not used at all later on in the program, but if I remove it, the program stops working. Any ideas? My code below: </p>
  
  <pre><code>import java.util.Scanner;
  /*
   * Name: Ki
   */
  public class Countdown {
      public static void main(String[] args) {
          //Create a Scanner object to accept the input from user
          Scanner input = new Scanner(System.in);
  
          // Prompt the user to enter starting number, I just set it to 5 because 
          // that's what the program had as standard input.
          System.out.println("Enter the beginning number: ");
  
          // I don't know how this works. I had this here as an experiment, but
          // the program now doesn't work without it so I guess I'll leave it here.
          int number = input.nextInt();
  
          // sets max countdown value
          int i=5;
  
          // Make a loop that makes the program countdown until it reaches 2
          while(i&gt;1) 
          {
              System.out.print(i + " ... \n");
              i--;
          }
          // Makes the program print 1 without dots and print stopped at the end 
          if (i==1) System.out.println(i);
          System.out.print("Stopped");
      }
  }
  </code></pre>