1public class ReplaceAllExample{
2public static void main(String args[]){
3String s1="Google is a very good website";
4String replaceString=s1.replaceAll("a","e");//replaces all occurrences of "a" to "e"
5System.out.println(replaceString);
6}}
1String s1 = "my name is khan and my name is java";
2String replaceString = s1.replace("is","was");
3//replaces all occurrences of "is" to "was"
4System.out.println(replaceString);