讨论hash键值的问题
C# code
Map map = new HashMap();
map.put("www.aa.com", "www.aaa.com");
map.put("b", "www.bbbb.com");
Iterator<?> it = map.keySet().iterator();
while(it.hasNext()){
String s = (String)map.get(it.next());
System.out.println(s);
}
map.remove("www.aa.com");
while(it.hasNext()){
String s = (String)map.get(it.next());
System.out.println(s);
}
www.bbbb.com作为键
为什么删不掉?
------解决方案--------------------
可以的
Map map = new HashMap();
map.put("www.aa.com", "www.aaa.com");
map.put("b", "www.bbbb.com");
Iterator<?> it = map.keySet().iterator();
while (it.hasNext())
{
String s = (String)map.get(it.next());
System.out.println("==" + s);
}
map.remove("www.aa.com");
it = map.keySet().iterator(); while (it.hasNext())
{
String s = (String)map.get(it.next());
System.out.println(s);
}