StringBuilder.insert - insert a string at position
public class InsertTest {
public static void main(String[] args){
StringBuilder sb = new StringBuilder("abcd");
sb.insert(sb.indexOf("b"),"word");// insert word at position of b
System.out.println(sb.toString());
}
}
OUTPUT:
awordbcd
No comments:
Post a Comment