日期:2014-05-20 浏览次数:20927 次
HashMap hp = new HashMap(); hp.put("1", "2"); System.out.println(hp.keySet());
------解决方案--------------------
HashMap m = new HashMap();
Set keys = m.keySet(); // 获取主键集合
------解决方案--------------------
import java.util.*; class MapTest{ public static void main(String[] args){ HashMap hm=new HashMap(); hm.put("one","aaa"); hm.put("two","bbb"); hm.put("three","ccc"); hm.put("four","ddd"); hm.remove("three"); hm.put("five","eee"); Set set=hm.entrySet(); Iterator it=set.iterator(); while(it.hasNext()){ Map.Entry me=(Map.Entry)it.next(); System.out.println(me.getKey()+":"+me.getValue()+":"+me.hashCode()); } } }
------解决方案--------------------
o
------解决方案--------------------
用 keySet() 方法
------解决方案--------------------
HashMap hsMap = new HashMap();
hsMap.put("one","aaa");
hsMap.put("two","bbb");
Enumeration eCol = htCol.keys();
while( eCol.hasMoreElements()){
System.out.println(eCol.nextElement());
}
给不给加分!!!!
------解决方案--------------------
import java.util.*;
class MapTest{
public static void main(String[] args){
HashMap hm=new HashMap();
hm.put("one","aaa");
hm.put("two","bbb");
hm.put("three","ccc");
hm.put("four","ddd");
hm.put("five","eee");
Set set=hm.entrySet();
Iterator it=set.iterator();
while(it.hasNext()){
Map.Entry me=(Map.Entry)it.next();
System.out.println(me.getKey()); }
}
}