Replaces only first occurrences of given String with new one and returns new String object.
publicclass Main {
publicstaticvoid main(String args[]) {
String str = "This is a test.";
System.out.println(str.replaceFirst("Th", "Ab"));
}
}
//Abis is a test.