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.


Signature

There are two type of replace methods in java string.

public String replace(char oldChar, char newChar)
and
public String replace(CharSequence target, CharSequence replacement)


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() method example

Flash soon



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

Flash soon



Copyright 2017 Design& Development