What is the reason behind the output of the following Java Code?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/5117132/integer-wrapper-objects-share-the-same-instances-only-within-the-value-127">Integer wrapper objects share the same instances only within the value 127?</a><br>
  <a href="http://stackoverflow.com/questions/8427416/why-is-true-for-some-integer-objects">Why is == true for some Integer objects?</a>  </p>
</blockquote>



<pre><code>class One
{
    public static void main(String[] args) 
    {
           Integer i1 = 10;
           Integer i2 = 10;

        if (i1 == i2) 
        {
            System.out.println("In if ");
        } 
        else
        {
            System.out.println("in else");
        }
    }
}
</code></pre>

<p>The output of the above program is <code>In if</code>
but if the values of i1 and i2 are changed to 1000 then output is In else.</p>

<p>I know that autoboxing is taking place here but unable to understand the  reasons of the output.
Thank You!</p>
