String replace(char oldChar, char newChar) method on Java

The replace(char oldChar, char newChar) method in Java returns a new string resulting from replacing all occurrences of oldChar in this string with newChar.

Syntax

Let us see the syntax,

Parameters

Let us see the parameters,

  • oldChar −  old character
  • newChar − new character

Example

The following is an example of replace(char oldChar, char newChar),

Output

The following is the output,

Java string replace method

String regionMatches(int toffset, String other, int ooffset, int len) method in Java
String replaceAll(String regex, String replacement) method in Java
Studyopedia Editorial Staff
contact@studyopedia.com

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading