Java String Function replace()
The java string replace() method returns a string replacing all the old char or CharSequence to new char or CharSequence.
Since JDK 1.5, a new replace() method is introduced, allowing you to replace a sequence of char values.
Java String replace(char old, char new) method example
public class ReplaceExample1{
public static void main(String args[]){
String s1="javatpoint is a very good website";
String replaceString=s1.replace('a','e');//replaces all occurrences of 'a' to 'e'
System.out.println(replaceString);
}}
Output:
jevetpoint is e very good websitejava java string