title: Java String pool - How strings are stored on heap
body: <p>Let's consider code below:</p>
  
  <pre><code>String s1 = "Hello world"
  String s2 = "Hello world XXX"
  </code></pre>
  
  <p>I guess, that those strings are stored two strings in Java String Pool:</p>
  
  <ul>
  <li>Hello world </li>
  <li>Hello world XXX</li>
  </ul>
  
  <p>How those strings are stored in memory of String Pool which is on heap? Are stored in special Heap for String Pool? Does any string's index exist for SP or those strings are stored in ordered collection? What happens if "Hello world AAA" is added into SP? Thanks.</p>