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 190 views
1 answer 175 views
1 answer 179 views
1 answer 168 views
1 answer 195 views
...