What is the output of the Java code? String s1 = "abc";
What is the output of the Java code?
String s1 = "abc";
String s2 = new String("abc");
System.out.println(s1 == s2);
System.out.println(s1.equals(s2));
Show answerHide answer
Correct answer: (B) false then true
Explanation
== compares references (different objects); equals() compares content.