public class A { static String s1 = \"I am A\"; public static void main(String[] args) { String s2 = \"I am A\"; System.out.println(s1 == s
Java manages a String literal pool. It reuses these literals when it can. Therefore the two objects are actually the same String object and == returns true.
String
==
I believe this is called string interning