Java Data Type Tutorial - Java StringBuffer.insert(int offset, Object obj)








Syntax

StringBuffer.insert(int offset, Object obj) has the following syntax.

public StringBuffer insert(int offset,   Object obj)

Example

In the following code shows how to use StringBuffer.insert(int offset, Object obj) method.

public class Main {
  public static void main(String args[]) {
    StringBuffer buffer = new StringBuffer();
//w  w w  .  j a  v a 2 s .  co  m
    Object objectRef = "java2s.com";
    buffer.insert(0, objectRef);
    System.out.println(buffer.toString());
    
  }
}

The code above generates the following result.