在Java中,如何用空格替换双引号?
例如:
"I don't like these "double" quotes"
我希望输出是
I don't like these double quotes
回答:
使用String#replace()
。
用空格替换它们(根据您的问题标题):
System.out.println("I don't like these \"double\" quotes".replace("\"", " "));
上面也可以用字符来完成:
System.out.println("I don't like these \"double\" quotes".replace('"', ' '));
删除它们(按照您的示例):
System.out.println("I don't like these \"double\" quotes".replace("\"", ""));
以上是 在Java中,如何用空格替换双引号? 的全部内容, 来源链接: utcz.com/qa/404878.html