title: Strange String pool behavior
body: <p>I've got a question of some strange String pool behavior.
  I'm using <code>==</code> to compare equal Strings to find out whether they're in the pool or not.</p>
  
  <pre><code>public class StringPoolTest {
    public static void main(String[] args) {
      new StringPoolTest().run();
    }
  
    String giveLiteralString() {
      return "555";
    }
  
    void run() {
      String s1 = giveLiteralString() + "";
      System.out.println("555" == "555" + "");
      System.out.println(giveLiteralString() == giveLiteralString() + "");
    }
  }
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>true
  false
  </code></pre>
  
  <p>which is a big surprise for me. Could anyone explain this please?
  I think something about this is taking place at the compilation time. But why does adding <code>""</code> to a String makes any difference at all?</p>