把错误代码贴全点,你可以自己设断点debug啊,一步步看是谁是空指针就可以了
class CountWords {
private String text;
private String[] words;
public CountWords(String text) {
this.text = text;
words = this.text.split("[ \n\t\r.,;:!?()]");
}
Map
public void printResult() {
你的split用了几种分割标准啊?