Why String and StringBuffer works differently, discrimination?
// Test.java public class Test { public static void main(String[] args) { String s1 = new String(“hello”); String s2 = new String(“hello”); StringBuffer sb1 = new StringBuffer(“hello”); StringBuffer sb2 = new StringBuffer(“hello”); System.out.println(“String: s1.equals(s2) = ” + s1.equals(s2)); System.out.println(“StringBuffer: sb1.equals(sb2) = ” + sb1.equals(sb2)); } } // output /* String: s1.equals(s2) = true StringBuffer: sb1.equals(sb2) = false */