gpt4 book ai didi

java - replaceAll() 工作一次,但不是两次?

转载 作者:行者123 更新时间:2023-11-29 09:51:58 26 4
gpt4 key购买 nike

<分区>

我有这个方法,它按预期工作:

public void splitReplaceAndPrint()
{
words = new String[200];

String bookReplacedWithNoCommas = book.replaceAll(",", "");

words = bookReplacedWithNoCommas.split(" ");

for(int i = 0; i < words.length; i++)
{
System.out.println(words[i]);
}
}

但是如果我也尝试删除这些点,就像这样......:

public void splitReplaceAndPrint()
{
words = new String[200];

String bookReplacedWithNoCommas = book.replaceAll(",", "");
String bookReplacedWithNoPoints = bookReplacedWithNoCommas.replaceAll(".", "");

words = bookReplacedWithNoPoints.split(" ");

for(int i = 0; i < words.length; i++)
{
System.out.println(words[i]);
}
}

... 没有打印任何内容。为什么这不起作用?

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com