String originalString = "The quick brown fox jumps over the lazy dog."; String replacedString = StringUtil.replace(originalString, "fox", "lemur"); System.out.println(replacedString); // Output: "The quick brown lemur jumps over the lazy dog."
String originalString = "She sells seashells by the seashore."; String replacedString = StringUtil.replace(originalString, "se", "ME"); System.out.println(replacedString); // Output: "ME sells MEashells by the MEashore."Here, we replace all occurrences of "se" with "ME", resulting in the `replacedString` variable. This method is useful for string manipulation and can be used in a variety of applications, including text editors, search functionality, and more.