What function can replace a string with another string?
Example #1: What will replace "HelloBrother" with "Brother"?
"HelloBrother"
"Brother"
Example #2: What will replace "JAVAISBEST" with "BEST"?
"JAVAISBEST"
"BEST"
The replace method is what you're looking for.
replace
For example:
String replacedString = someString.replace("HelloBrother", "Brother");
2.1m questions
2.1m answers
60 comments
57.0k users