Mega Code Archive

 
Categories / Java Tutorial / Data Type
 

Replaces only first occourances of given String with new one and returns new String object

public class Main {   public static void main(String args[]) {     String str = "This is a test.";     System.out.println(str.replaceFirst("Th", "Ab"));   } } //Abis is a test.