Javatpoint Logo
Javatpoint Logo

Java String replace()

The java string replace() method returns a string replacing all the old char or CharSequence to new char or CharSequence.

Since JDK 1.5, a new replace() method is introduced, allowing you to replace a sequence of char values.


Internal implementation


Signature

There are two type of replace methods in java string.

The second replace method is added since JDK 1.5.


Parameters

oldChar : old character

newChar : new character

target : target sequence of characters

replacement : replacement sequence of characters


Returns

replaced string


Java String replace(char old, char new) method example

Test it Now
jevetpoint is e very good website

Java String replace(CharSequence target, CharSequence replacement) method example

Test it Now
my name was khan my name was java

Java String replace() Method Example 3

oooooo-ssss-oooooo
oooooo-hhhh-oooooo




Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA