力扣上的一道题目 819. 最常见的单词,我用java写了代码不知道出错原因,求解

class Solution {
    public String mostCommonWord(String paragraph, String[] banned) {
        HashSet<String> banset = new HashSet<String>();
        for(int i=0; i<banned.length;i++) {
            banset.add(banned[i]);
        }
        String msword="";
        int mscount=0;
        HashMap<String,Integer> count = new HashMap<String,Integer>();
        String[] words = paragraph.split("[!?',;. ]"); 
        for(int i=0; i<words.length;i++) {
            String key = words[i].toLowerCase();
            if(key.length()>0) {
                if(!banset.contains(key)) {
                    count.put(key,count.getOrDefault(key, 0)+1);
                }
                if(count.get(key)>=mscount) {    //这一行出错,说是空指针异常,不懂
                    mscount = count.get(key);
                    msword = key;
                }
            }
    }
        return msword;
    }
}

原因:
java.lang.NullPointerException
at line 19, Solution.mostCommonWord
at line 54, DriverSolution.helper
at line 87, Driver.maind

空指针异常,就是你的数据容器里面没有数据是空的
检查你的方法传递过来的数据有没有问题
就是没有数据的表现

我找到错误了,
这一段应该在上个if语句之内

 if(count.get(key)>=mscount) {    //这一行出错,说是空指针异常,不懂
                    mscount = count.get(key);
                    msword = key;
                }