I have created a basic program, but the output is the same, so what is the diff between the?
public class Main
{
public static void main(String[] args) {
String str1 ="Hello is Hello";
System.out.println(str1.replace("Hello", "Good"));
System.out.println(str1.replaceAll("Hello", "Good"));
}
}
Instructor
Ashish Thakur Replied on 12/07/2022
str1="ABCD EFGH ABCD"
System.out.println(str1.replace("ABCD", "XYZ")); -> XYZ EFGH ABCD
System.out.println(str1.replaceAll("ABCD", "XYZ")); -> XYZ EFGH XYZ