Memory allocation/reference comparison for ints and Integers
<p>With the following:</p>

<pre><code>String a = new String("test");
String b = "test";
System.out.println(a == b); //false
</code></pre>

<p>We get false, since <code>String a</code> is an object, so <code>a</code> points to a different location in memory than the string literal, <code>b</code>.  I wanted to see how this worked for <code>int</code> and <code>Integer</code>:</p>

<pre><code>Integer x = new Integer(5);
int y =5;
System.out.println(x == y); //true
</code></pre>

<p>I though that <code>x.equals(y)</code> would be true, but <code>x == y</code> would be false as it is in the case with <code>Strings</code>.  I understand that we compare <code>ints</code> with <code>==</code>, but I figured that comparing an <code>int</code> to an <code>Integer</code> would be different.  Why is this not the case?</p>

<p>I assume that in this case using <code>==</code> won't work for comparing references, so how would we do it (not sure if this is practical, but I'd like to know)?</p>
