The example aims to create and build StringBuffer with different constructors in Java.
Source Code
package com.beginner.examples;
public class CreateStringBuffer {
public static void main(String[] args) {
//Create empty StringBuffe.
StringBuffer stringBuffer1 = new StringBuffer();
//Create with the contents StringBuffe.
StringBuffer stringBuffer2 = new StringBuffer("Hello World");
System.out.println(stringBuffer2);
}
}
Output:
Hello World