How to insert a string into a StringBuilder at a given position in Java

1 Answer

0 votes
public class MyClass {
    public static void main(String args[]) {
        StringBuilder sb = new StringBuilder("Java");  

        sb.insert(4, " Programming");
        
        System.out.println(sb);
    }
}



/*
run:

Java Programming

*/

 



answered Jun 15, 2019 by avibootz
edited Jun 16, 2019 by avibootz
...