String.trim() returning false for same referenced object
<p>Why is this <strong>false</strong>?</p>

<pre><code>String str1 = new String("Java    ");
String str2 = str1;
System.out.println(str1.trim()==str2.trim());  //false
</code></pre>

<p>Initially <code>str2</code> was referencing <code>str1</code> object. So, comparing with == will return true for <code>str1==str2</code></p>

<p>Then why is this <strong>false</strong> with <code>.trim()</code> method?</p>

<p>Even it returns false for literals (without new keyword)</p>

<pre><code>String str1 = "Java    ";  //this is now without new keyword
String str2 = str1;
System.out.println(str1.trim()==str2.trim());
</code></pre>

<p>Note: I know how to use <code>.equals</code> method. But want to know <code>==</code> behavior especially in case of .trim() with above given two example.</p>
