Let’s see the difference between String and StringBuffer in java.
|String is a immutable class which implements comparable interface.||StringBuffer is a mutable class which does't implements Comparable interface.|
|We can create object of String in two ways without new operator and with new operator.||We can create StringBuffer object only with new operator.|
|String uses String constant pool mechanism in order to reuse the objects.||There is no concept in case of StringBuffer.|
|String methods are not synchronized.||All StringBuffer methods are synchronized.|
|We can compare two string using compareT0() method||We can't compare two StringBuffer object using compareTo() method.|
|String Overrides hashCode() and equals() methods.||StringBuffer doesn't overrides hasCode() and equals() methods.|