12
Dec
String replace method is: String.replace(“oldValue”,”newValue”);
public class Main {
public static void main(String[] args) {
String sentence1="Java programming is very hard";
String newSentence=sentence1.replace("hard","easy");
System.out.println(newSentence);
}
}
Output:
Java programming is very easy
Leave a Reply