Java Data Type Tutorial - Java StringBuilder.insert(int offset, char c)








Syntax

StringBuilder.insert(int offset, char c) has the following syntax.

public StringBuilder insert(int offset,   char c)

Example

In the following code shows how to use StringBuilder.insert(int offset, char c) method.

public class Main {
  public static void main(String args[]) {
    StringBuilder buffer = new StringBuilder();
/* w  w w .  j  a va  2 s  .  co m*/

    char characterValue = 'K';
    buffer.insert(0, characterValue);

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

The code above generates the following result.