Java String Replace
Chapter:
String Handling
Last Updated:
20-08-2016 17:54:31 UTC
Program:
/* ............... START ............... */
public class JavaStringReplaceExample {
public static void main(String args[]) {
String str = "Hello World";
System.out.println(str.replace('H', 'W'));
System.out.println(str.replaceFirst("He", "Wa"));
System.out.println(str.replaceAll("He", "Ha"));
}
}
/* ............... END ............... */
Output
Wello World
Wallo World
Hallo World
Tags
String Replace, Java, String