获取hashmap中的key和value的方法

//定义一个键值都为整形的hash表
Map occurrences = new HashMap();
//进行遍历
for (Map.Entry entry : occurrences.entrySet()) {
int num = entry.getKey();
int count = entry.getValue();
}
其中 num代表遍历出来的key,count代表遍历出来的value

你可能感兴趣的:(hashmap)