Comparing Integers in Java
<p>I got the following code from a Java book that didn't have explanation about the results. I ran it and got the results noted below inline, but I need help understanding the results:</p>

<pre><code>1. Integer i = -10;
2. Integer j = -10;
3. System.out.print(i==j);  //  ==&gt; true
4. System.out.print(i.equals(j));   //  ==&gt; true
5. Integer n = 128;
6. Integer m = 128;
7. System.out.print(n==m);  //  ==&gt; false
8. System.out.print(n.equals(m));   //  ==&gt; true
</code></pre>

<p>My questions are:</p>

<ul>
<li>why does line #3 resolve to true? are they not two separate objects?</li>
<li>if line #3 is true, why does line #7 not true?</li>
</ul>

<p>Thanks if advance.</p>
