title: Comparing Integer objects vs int
body: <p>I fixed an endless loop by changing Integer to int in the following:</p>
  
  <pre><code>public class IntTest {
      public static void main(String[] args) {
          Integer x=-1;
          Integer total=1000;
  
          while(x != total){
              System.out.println("x =" + x + "total ="+ total);
              x++;
          }
      }
  }
  </code></pre>
  
  <p>What is the proper reason for this?  I figured Integer would compare no problem.</p>
  
  <p>Thanks.</p>