Object equal method?
<p>Below is written in javadocs</p>

<blockquote>
  <p>The equals method for class Object implements the most discriminating
  possible equivalence relation on objects; that is, for any non-null
  reference values x and y, this method returns true if and only if x
  and y refer to the same object (x == y has the value true).</p>
</blockquote>

<p>Does it mean object1.equals(object2) return true only when object1==object2.</p>

<p>Below example at <a href="http://stackoverflow.com/questions/1175620/in-java-what-is-a-shallow-copy">In Java, what is a shallow copy?</a></p>

<pre><code>class Foo { private Bar myBar; ... 
public Foo shallowCopy() { 
 Foo newFoo = new Foo(); newFoo.myBar = myBar; return newFoo; }  
public Foo deepCopy() { Foo newFoo = new Foo(); newFoo.myBar = myBar.clone(); //or new Bar(myBar) or myBar.deepCopy or ... return newFoo; } } Foo myFoo = new Foo();
Foo sFoo = myFoo.shallowCopy();
Foo dFoo = myFoo.deepCopy(); 

myFoo.myBar == sFoo.myBar =&gt; true
myFoo.myBar.equals(sFoo.myBar) =&gt; true
myFoo.myBar == dFoo.myBar =&gt; false
myFoo.myBar.equals(dFoo.myBar) =&gt; true 
</code></pre>

<p>If First understading is correct how  come myFoo.myBar.equals(dFoo.myBar) => true </p>
