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:
Related Posts:
Character Extraction
Character Extraction:
2)getChars()
If you want to extract more than one character at a time,you can use the getChars() method.
It has general form… Read More
String Length in java
String Length in java:
The length of the String is the actual number of character that contains in it.To get this value,call the length() method as … Read More
replace() method
Modifying a String:
replace();
The replace method is used to replace the one character of string.It has the general form:
&nbs… Read More
Character Extraction
Character Extraction:
1) charAt()
charAt() method is used to extract single character from String.Here is a small program to demonstrate chatAt() … Read More
Access Protection in java:
Access Protection in java:
private No modifier protected public
Same class … Read More
0 comments:
Post a Comment