<分区>
我有这个方法,它按预期工作:
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]);
}
}
... 没有打印任何内容。为什么这不起作用?