title: Endless java loop while taking an input
body: <p>I have this problem with a while loop here:</p>
  
  <pre><code>while((input = InputHandler.getInt()) != 1 &amp;&amp; input != 2){
          if(input == InputHandler.CODE_ERROR)
              System.out.print("Input must be a number");
      }
  </code></pre>
  
  <p>This while loop takes in an input only once and doesn't ask for it again, so it loops with that input taken once the entire time. What am I doing wrong here, because to me it's really strange the this wile loop is working?</p>
  
  <p>InputHandler class:</p>
  
  <pre><code>public class InputHandler {
    public static Scanner in = new Scanner(System.in);
    public static int CODE_ERROR = -6;
  
    public static int getInt(){
      try{
          return in.nextInt();
      } catch(InputMismatchException e){
          return CODE_ERROR;
      }
    }
  }
  </code></pre>