- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Replace String with another in java.
The replace() method of the returns a new string resulting from replacing all occurrences of oldChar in this string with newChar.
Example
import java.io.*; public class Test { public static void main(String args[]) { String Str = new String("Welcome to Tutorialspoint.com"); System.out.print("Return Value :" ); System.out.println(Str.replace('o', 'T')); System.out.print("Return Value :" ); System.out.println(Str.replace('l', 'D')); } }
Output
Return Value :WelcTme tT TutTrialspTint.cTm Return Value :WeDcome to TutoriaDspoint.com
- Related Articles
- Replace one string with another string with Java Regular Expressions
- Replace all words with another string with Java Regular Expressions
- Replace part of a string with another string in C++
- How to replace all occurrences of a string with another string in Python?
- How to replace all occurrences of a word in a string with another word in java?
- Java Program to replace one specific character with another
- How to replace total string if partial string matches with another string in R data frame column?
- Replace substring with another substring C++
- How to use JavaScript to replace a portion of string with another value?
- Java String replace() method example.
- Replace Character in a String in Java without using replace() method
- Java String replace(), replaceFirst() & replaceAll() Methods
- Insert a String into another String in Java
- How to replace characters on String in Java?
- How can we replace all the occurrences of a substring with another substring within a string in MySQL?

Advertisements