When you use Strings and have two Strings which are compile time constants, the JVM uses the same String objectString s1 = "Campbell"; String s2 = "Campbell"; System.out.printf("s1 == s2: %b%n", s1 == s2);Try that, and you find the two references point to the same String object. When you use some wrapper objects, something rather similar happens. It happens for Integers; ...