我怎样才能获得 Map 的子视图,然后将元素从它上面交叉,徒劳地试一试。这是我的代码片段:
HashMap<String,Integer> myLinkedHashMap = new LinkedHashMap<String, Integer>(1,1,true);
myLinkedHashMap.put("a", 2);
myLinkedHashMap.put("b", 3);
myLinkedHashMap.put("c", 4);
Set keysView = myLinkedHashMap.keySet();
keysView.remove("a"); // worked without a hitch
Collection valuesView = myLinkedHashMap.values();
valuesView.remove(4); // like the last one
这就是我的问题归结为:
Set<Entry<String,Integer>> associationsView = myLinkedHashMap.entrySet();
associationsView.remove("Nothing doing,for set does not know about key/value thing");
伸出援助之手将不胜感激,谢谢。