如图所示, 报错 Object cannot be converted to Entry<Character,Integer>
for(Map.Entry<Character,Integer> entry:map.entrySet())
,这问题出在哪里呢?
HashMap<Character, Integer> map = new HashMap<>();
这样初始化
一般情况下,我们用Map都是用父类来声明:Map<Character, Integer> map = new HashMap<Character, Integer>();