Write a program to replace a string

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
about author

admin

salmansrabon@gmail.com

If you like my post or If you have any queries, do not hesitate to leave a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *