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








Syntax

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

public StringBuffer insert(int offset,   int i)

Example

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

// ww  w  .ja v  a  2 s .c o  m

public class Main {
  public static void main(String args[]) {
    StringBuffer buffer = new StringBuffer();


    int integerValue = 7;
    buffer.insert(0, integerValue);

    System.out.println(buffer.toString());
    
  }
}

The code above generates the following result.