In this article, we will see how to use replace method of String class in Java.
In Java, Strings, we can use replace method to replace a char acter sequence in a String object.
Lets look to our code.
String x = "abc";
System.out.println(x.replace("x","xx"));
Lets see it in an example.
In above example, we created two String object. We used replace method to change "x" as "xx" in String.