programming-examples/java/_Basics/How to replace a substring inside a string by another one.java
2019-11-15 12:59:38 +01:00

8 lines
299 B
Java

public class StringReplaceEmp {
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") );
}
}