在Java中替换String中的单词

时间:2019-02-11 12:55:48

标签: java

我们如何在字符串“ That”中更改“ the”和“ That”的值。“这是真实故事。这本书的故事是关于一个英雄,她的妻子和他们的孩子”

1 个答案:

答案 0 :(得分:-1)

您本可以对String类进行更多研究,这是一个可用的方法。

String sentence = "There is the book of Real Story. The Story behind the book is about a hero her wife and Their children";
sentence.replace("the","that");