This Java program replaces all occurrences of a given character in a String with another character using the replace() method and prints the resulting String.
public class Replace_Char { public static void main(String[] args) { String str1 = "Java Exercise"; String str2 = str1.replace('e', 'Q'); System.out.println("Given String : " + str1); System.out.println("After String Character Replace : " + str2); } }
Given String : Java Exercise After String Character Replace : Java ExQrcisQ
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions