String str=new String(“hello”);
StringBuffers are mutable objects.StringBuffer are continuous sequence of characters. StringBuffers are Thread Safe.
StringBuffer str=new StringBuffer(“zulqarnain”);
StringBuilders are mutable objects. StringBuilders are not Thread Safe
StringBuilder str=new StringBuilder(“hello”);
Why and when Using StringBuffer and StringBuilder
StringBuffer and StringBuilder should be used when lot of modification requires in string characters .
If continuous changes required in string character and using String object you are making waist of memory (String pool objects).