下面的代码用于输出字符数组ch中每个字符出现的次数,应该填入的代码是( )public static void main(String[] args) { char[] ch = { ’a’, ’c’, ’a’, ’b’, ’c’, ’b’ }; HashMap map = new HashMap(); for (int i = 0; i < ch.length; i++) { < 填入代码 > } System.out.println(map); }
A、if (map.contains(ch[i])) { map.put(ch[i], map.get(ch[i]) + 1); } else { map.put(ch[i], 1); }
B、if (map.contains(ch[i])) { map.put(ch[i], (Integer) map.get(ch[i]) + 1); } else { map.put(ch[i], 1); }
C、if (map.containsKey(ch[i])) { map.put(ch[i], (int) map.get(ch[i]) + 1); } else { map.put(ch[i], 1); }
D、if (map.containsKey(ch[i])) { map.put(ch[i], (Integer) map.get(ch[i]) + 1); } else { map.put(ch[i], 1); }
A.length;
B.out.println(map);
C.contains(ch[i]))
D.put(ch[i],
E.get(ch[i])
F.put(ch[i],
G.contains(ch[i]))
H.put(ch[i],
I.get(ch[i])
J.put(ch[i],
K.containsKey(ch[i]))
L.put(ch[i],
M.get(ch[i])
N.put(ch[i],
O.containsKey(ch[i]))
P.put(ch[i],
Q.get(ch[i])
R.put(ch[i],