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

Code Example 1

String s1 = "my name is khan and my name is java";
String replaceString = s1.replace("is","was");
//replaces all occurrences of "is" to "was"
System.out.println(replaceString);

Learn ReactJs, React Native from akashmittal.com