有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

字符串非常简单:用Java编写“”

这是一个最微不足道的问题,但我不知道如何解决这个问题

在一个字符串中,我想用“this”来关联这个字符串的所有出现

我的问题是编译器不允许我写“”或“”(希望这有意义)

所以我的代码是:

s = s.replace('"', '""'); // so the 2nd parameter of the method is causing an error

我希望这是有道理的:p


共 (1) 个答案

  1. # 1 楼答案

    编辑:(根据建议使用replace而不是replaceAll)

    s = s.replace("\"", "\"\"");