请问怎样取得hashmap中所有关键字的值,谢谢
------解决方案--------------------
map.keySet
------解决方案--------------------
Map hm=new Hashmap();
hm.put( "a ", "A ");
Iterator it = hm.entrySet().iterator();
while (it.hasNext()) {
Object key =it.next();//取出 "a "
Object value=hm.get(key);//取出 "A "
}
Map map = new HashMap();
map.set( "a ", "b ");
Iterator it = map.keySet().iterator();
while (it.hasNext()) {
Object key =it.next();
System.out.println( "key is "+key);//
System.out.println( "value is "+map.get(key));
}
------解决方案--------------------
Set set = hm.keySet();
Iterator it = set.iterator();
while(it.hasNext())
{
System.out.println(it.next());
}