public
String replace(char oldChar, char newChar)
return
a string derived from this string by replacing every occurrence of
oldChar with newChar.
class StringReplace{ public static void main(String args[]){ String s1 = "aaaaa"; String s2 = s1.replace('a', 'A'); System.out.println("s1 = " + s1); System.out.println("s2 = " + s2); } }
Output
s1 = aaaaa s2 = AAAAA
No comments:
Post a Comment