The
replace() is used to replace a character or a sequence of characters of an invoking string with a desired character or set of characters .
The
replace has two forms:String replace(char original, char replacement) This form is used to replace a character with a desired character in the invoking string. Here original specifies the character to be replaced, replacement specifies the character that replaces original .The other form of replace is: String replace(CharSequence original, CharSequence replacement) This form is used to replace a charactersequence with a desired charactersequence in the invoking string. Here also original specifies the character sequence to be replaced, replacement specifies the character sequence that replaces original .The following program demonstrates replace :
replace CODE class ReplaceDemo OUTPUT Moon is bright DESCRIPTION At THINGS TO TRY
Dependent Topics :
|