首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

讨论hash键值的有关问题

2012-01-08 
讨论hash键值的问题C# codeMap map new HashMap()map.put(www.aa.com, www.aaa.com)map.put(b,

讨论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);
}

热点排行
Bad Request.