oldChar
in this string with newChar
. If the character oldChar
does not occur in the character sequence represented by this String
object, then a reference to this String
object is returned. Otherwise, a new String
object is created that represents a character sequence identical to the character sequence represented by this String
object, except that every occurrence of oldChar
is replaced by an occurrence of newChar
.
Examples:
@param oldChar the old character. @param newChar the new character. @return a string derived from this string by replacing everyoccurrence of"mesquite in your cellar".replace('e', 'o') returns "mosquito in your collar" "the war of baronets".replace('r', 'y') returns "the way of bayonets" "sparring with a purple porpoise".replace('p', 't') returns "starring with a turtle tortoise" "JonL".replace('q', 'x') returns "JonL" (no change)
oldChar
with newChar
.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|