title: Primitive wrappers comparison
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/10149959/using-operator-in-java-to-compare-wrapper-objects">Using == operator in Java to compare wrapper objects</a>  </p>
  </blockquote>
  
  
  
  <p><strong>java version 1.6.0_26</strong></p>
  
  <p><strong>From a book</strong> for SCJP exam preparation:</p>
  
  <p><em>In order to save memory, two instance of the following[Short and Integer from -128 and 127, and some other but doesn't matter for question] wrapper objects (created throught boixng), will always be == when their primitive values are the same.</em></p>
  
  <p><strong>What I did:</strong></p>
  
  <p>If we will compare two integer from -128 to 127 like this:</p>
  
  <pre><code>1. Integer i1 = 10;
  2. Integer i2 = 10;
  3. System.out.println(i1 == i2); // true
  </code></pre>
  
  <p>But why the same give us "false" or may be it's not the same things:</p>
  
  <pre><code>4. Integer i3 = new Integer(10);
  5. Integer i4 = new Integer(10);
  6. System.out.println(i3 == i4); // false
  </code></pre>
  
  <p>My questions: </p>
  
  <p>1) Does on the 1st line of code we make implicit boxing?</p>
  
  <p>2) Why the 3rd and 6th lines of code give us different results?</p>