+ 2

Explain how it's output is falsefalsefalsetrue

class String1 { public static void main(String[] arg) { StringBuffer sb1 = new StringBuffer("Hello"); StringBuffer sb2 = new StringBuffer("Hello"); String s1 = new String("Hello"); String s2 = new String("Hello"); System.out.print(sb1.equals(sb2)); System.out.print(s1 == s2); System.out.print(sb1 == sb2); System.out.print(s1.equals(s2)); } }

30th Nov 2023, 4:46 AM
Dipen Sejpal
Dipen Sejpal - avatar
2 Réponses
+ 3
30th Nov 2023, 5:15 AM
A͢J
A͢J - avatar
30th Nov 2023, 5:21 AM
Wong Hei Ming
Wong Hei Ming - avatar