replace( ) method is used to replace a specific character in the provided string with another character.
Example:
"is is is is is".replace('i','a'); -> This will replace the character 'i' in "is" string to 'a' ,so that the output string is "as as as as as".
Lets implement this on Eclipse IDE:
1. Create 'replaceDemo' class under any project as shown below:
2. Save and Run the 'replaceDemo' class file
3. Observe that the output is displayed in the console as shown below:
Download this project:
Click here to download this project containing the class file used in this post (You can download this project and import into Eclipse IDE on your machine)
Example:
"is is is is is".replace('i','a'); -> This will replace the character 'i' in "is" string to 'a' ,so that the output string is "as as as as as".
Lets implement this on Eclipse IDE:
1. Create 'replaceDemo' class under any project as shown below:
3. Observe that the output is displayed in the console as shown below:
Download this project:
Click here to download this project containing the class file used in this post (You can download this project and import into Eclipse IDE on your machine)