The behaviour of equals() method in Java
<p>Consider the following Java code:      </p>

<pre><code>    Object a = new Integer(2);
    Object b = new Integer(2);
    System.out.println(a.equals(b));

    Object x = new Object();
    Object y = new Object();
    System.out.println(x.equals(y));
</code></pre>

<p>The first print statement prints <code>true</code> and the second <code>false</code>.</p>

<p>If this is an intentional behavior, how this helps programming in Java?</p>

<p>If this is not an intentional behavior, is this a defect in Java?</p>
