java.lang.String.replaceFirst

In the example, we are going to show you how to implement the replaceFirst() method in Java application.

java.lang.String.replaceFirst

In the example, we are going to show you how to implement the replaceFirst() method in Java application.

Generally, replaceFirst() method in Java used to replace the first substring, matching the given regular expression with the given replacement.

A simple example of replaceFirst() method.

public class example {
public static void main(String args[]) {
String xx = "test";
xx = xx.replaceFirst("t","z");
System.out.println(xx);
  }
}

the Output is:
zest