replace(..) method is used to replace an existing character with a new character.
public class Test{
public static void main(String[] arg){
String firstString = "Hello";
String newString=firstString.replace('l','g');
System.out.println("The new String is : "+newString);
}
}
It replaces all ls with g.