Answers for "how to append character at any position in stringbuilder"

0

how to append character at any position in stringbuilder

The java.lang.StringBuilder.insert(int offset, char c) method inserts the 
string representation of the char argument into this sequence.

The second argument is inserted into the contents of this 
sequence at the position indicated by offset.
The length of this sequence increases by one.
The offset argument must be greater than or equal to 0, and less than 
or equal to the length of this sequence.
________________________________________________
public StringBuilder insert(int offset, char c)

________________________________________________
Example:-
 StringBuilder str = new StringBuilder("Jinal Patel");
      System.out.println("string = " + str);

      // insert character value at offset 8
      str.insert(8, 'h');
Posted by: Guest on August-09-2021

Code answers related to "how to append character at any position in stringbuilder"

Browse Popular Code Answers by Language