Modifying a String:
replace();
The replace method is used to replace the one character of string.It has the general form:
String replace(char original,char replace);
Here is a small program to show how replace() method works:
package stringdemo;
public class ReplaceDemo {
public static void main(String[] args) {
String s="HelloWorld";
System.out.println(s.replace("H", "W"));
}
}
Output:
WelloWorld
0 comments:
Post a Comment