Is Java String really immutable?
<p>In String source it looks like the hash code value (private int hashCode) is set only if the method public int hashCode() was called at least once. That means a different state. But will the hashCode be set in the following example: </p>

<pre><code>String s = "ABC"; ? 
</code></pre>

<p>Will </p>

<pre><code>String s = "ABC"; 
s.hashCode();
</code></pre>

<p>help with subsequent comparisons performance?</p>
