StringBuffer.insert(int offset, String str) has the following syntax.
public StringBuffer insert(int offset, String str)
In the following code shows how to use StringBuffer.insert(int offset, String str) method.
// w w w . java 2s. c o m public class Main { public static void main(String args[]) { StringBuffer buffer = new StringBuffer(); String string = "java2s.com"; buffer.insert(0, string); System.out.println(buffer.toString()); } }
The code above generates the following result.