string.replace()
String.replace() Replace all occurrence of matching char or string .
Here are some examples with output.
Replacing char
String str = "Welcome to plus2net.com";
System.out.println(str.replace("o","*"));
Output is here
Welc*me t* plus2net.c*m
Replacing string
String str = "Welcome to plus2net.com";
System.out.println(str.replace("com","net"));
Output is here
Welnete to plus2net.net
Note : In above code there are two replacements.
« All String functions
This article is written by plus2net.com team.
plus2net.com