1public static void main(String args[]){
2String s1="my name is khan my name is java";
3String replaceString=s1.replace("is","was");//replaces all occurrences of "is" to "was"
4System.out.println(replaceString);
5}}
6
1String str1 = "abc123abc123";
2String str2 = str1.replace("abc", "0");
3System.out.println(str2); // 01230123
4
1String str = "..............................";
2
3 int index = 5;
4
5 char ch = '|';
6
7 StringBuilder string = new StringBuilder(str);
8 string.setCharAt(index, ch);
9
10 System.out.println(string);
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);
1public static void main(String args[]){
2String s1="my name is khan my name is java";
3String replaceString=s1.replace("is","was");//replaces all occurrences of "is" to "was"
4System.out.println(replaceString);
5}}