What is the use of the replace() method of the String class?
March 8th, 2008 by uCertify
Leave a reply »
The replace() method of the String class replaces a given character in a given string with a new character. The general syntax for this method is as follows:
public String replace(char oldChar, char newChar)
For example, Sting s=”Hello”;
Now the following syntax will replace all the l’s in this string with m’s:
s.replace(’l', ‘m’);
Get certified in first attempt download scja - SCJA simulation.
Best exam simulation SUN CX310-019 download free trial.