HashMap
作者:互联网
- Type argument cannot be of primitive type
HashMap<Integer,boolean> hashMap = new HashMap<Integer, boolean>();
it should use Boolean instead of boolean;
hashMap.setEntry 是一个包装了每一个hashmap key-value的一个entry
for里面的内容左边是类型 这个函数的返回值类型为 Map.Entry<Integer,Boolean>
SO:this method return a Set view of the mapping contained in the map(hashmap)
Syntax:Set<Map.Entry<K,V>> entrySet()
``
HashMap<Integer, Boolean> hashMap = new HashMap<Integer, Boolean>();
hashMap.put(1,hashMap.containsValue(2));
hashMap.put(4,hashMap.containsValue(2));
for(Map.Entry<Integer,Boolean> entry : hashMap.entrySet()){
System.out.println(entry.getKey()+":"+entry.getValue());
}
``
标签:hashmap,entrySet,hashMap,Entry,entry,HashMap 来源: https://www.cnblogs.com/ldphoebe/p/16478867.html