How to set (replace) a character at specific index in StringBuffer with Java

1 Answer

0 votes
public class MyClass {
    public static void main(String args[]) {
        StringBuffer sb = new StringBuffer("PHP Java C++ C# C Python"); 

        sb.setCharAt(7, 'W'); 
        
        System.out.println(sb); 
    }
}



/*
run:

PHP JavW C++ C# C Python

*/

 



answered Apr 23, 2020 by avibootz
edited Apr 23, 2020 by avibootz

Related questions

...