Strings, which are widely used in Java programming, are a sequence of characters. In Java programming language, strings are treated as objects. The Java platform provides the String class to create and manipulate strings.
Whereas, StringBuffer class is a thread-safe, mutable sequence of characters.
public class Sample { public static void main(String args[]) { String str = new String("Hi welcome to tutorialspoint"); System.out.println(str);StringBuffer sBuffer = new StringBuffer("test"); sBuffer.append(" String Buffer"); System.out.println(sBuffer); } }
Hi welcome to tutorialspoint test String Buffer