String, StringBuilder, StringBuffer (Mutable vs Immutable Objects)
Difference between String and StringBuffer/StringBuilder String is immutable objects means once created it cannot be changed, reference will point to new object. If our application has string manipulation activity, then there will be many discarded string object in heap memory which might result in performance impact. StringBuffer/StringBuilder is mutable StringBuffer/StringBuilder can have characters/strings may be inserted in between or appended at end for which the StringBuffer/StringBuilder automatically grow Difference between StringBuffer & StringBuilder Methods in StringBuilder are not synchronized hence better performance over StringBuffer Methods in StringBuilder are not synchronized hence it is not thread safe Examples with basic methods String public class StringDemo { public static void main (String[] args) { // Following are 2 ways to instantiate String object String s=new String("ABCDMNOP"); String s1="PqRS...