String a = "ab"; String b = new String("ab"); System.out.println(a == b); System.out.println(a.equals(b)); System.out.println(b.intern() == a); System.out.println(a.intern() == b);