Check out example codes for "java replace character in string". It will help you in understanding the concepts better.

Code Example 1

String s = "new String";
String replaced = s.replace("new","Test");
							  ^		 ^
                             old    new char

Code Example 2

String str = ".............................."; 

        int index = 5; 
  
        char ch = '|'; 
 
        StringBuilder string = new StringBuilder(str); 
        string.setCharAt(index, ch); 

        System.out.println(string);

Learn ReactJs, React Native from akashmittal.com