Java string replace:string character whitespace vowel regex
Here we will see Java string replace examples with replacing the string, replacing characters, replacing whitespace vowels, and using a regular expression to replace string and substring. Java string replace Example: use of replace() Java String replace() is used to replace substring in given string.
1 2 3 4 5 6 7 8 9 | public class JavaString { public static void main(String[] args) { String s1 = " My Name is Joker"; String s2 = s1.replace("Joker", "Poker"); System.out.println("Old String : " + s1); System.out.println("New String : " + s2); } } |
In this example, Joker is replaced with Poker and … Read more