<分区>
我想创建一个程序,在用户输入的字符串中给出字符、单词等的数量。为了获得字数统计,我需要删除所有句点和逗号形成一个字符串。到目前为止我有这个:
import javax.swing.JOptionPane;
public class WordUtilities
{
public static void main(String args[])
{
{
String s = JOptionPane.showInputDialog("Enter in any text.");
int a = s.length();
String str = s.replaceAll(",", "");
String str1 = str.replaceAll(".", "");
System.out.println("Number of characters: " + a);
System.out.println(str1);
}
}
}
但最后我只得到了这个:
Number of characters: (...)
为什么不给我没有逗号和句点的字符串?我需要修复什么?