Programs use the same string literals again and again, so Java keeps one shared copy of each in the string pool to save memory. This is why two identical literals are == while new String("x") is not. It explains many confusing predict-the-output questions about string comparison. In real code, do not rely on the pool for comparisons; always use equals().