Which one statement is true about the following code?
1. String s1 = "abc" + "def"; 2. String s2 = new String(s1); 3. if (s1 == s2) 4. System.out.println("== succeeded"); 5. if (s1.equals(s2)) 6. System.out.println(".equals() succeeded");
C.
Because s1 and s2 are references to two different objects, the == test fails.
However, the strings contained within the two String objects are identical, so the equals()
test passes.