I have a string thats a sentence and I would like to replace all instances of the character 't' with a string "foo" and 'h' with "bar".
String sentence = "The tea is hot.";
The ending result I’m trying to achieve:
"The fooea is fooobar."
Is this possible?
Use
replace:replaceAlltakes a regular expressions when it is not needed here (and will therefore not be as efficient asreplace).Relevant documentation
replace