How to replace substring from StringBuilder from index to index in Java

1 Answer

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

        sb.replace(1, 3, "C++");  
        
        System.out.println(sb);
    }
}



/*
run:

JC++a

*/

 



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

Related questions

1 answer 169 views
1 answer 154 views
1 answer 166 views
1 answer 147 views
1 answer 184 views
...