Java Examples - string replacement
Java Examples - string replacement
How to use java replacement string of characters?
The following examples we used replace java String class method to replace a string of characters:
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") ); } }
The output is the above code examples:
Wello World Wallo World Hallo World