Using == when comparing objects
<p>Recently in a job interview I was asked this following question (for Java):</p>

<p>Given:</p>

<pre><code>String s1 = "abc";
String s2 = "abc";
</code></pre>

<p>What is the return value of </p>

<pre><code>(s1 == s2)
</code></pre>

<p>I answered with it would return false because they are two different objects and == is a memory address comparison rather than a value comparison, and that one would need to use .equals() to compare String objects. I was however told that although the .equals(0 methodology was right, the statement nonetheless returns true. I was wondering if someone could explain this to me as to why it is true but why we are still taught in school to use equals()?</p>
