HashMap中怎么取得所有的键值对啊? 如题:HashMap中怎么取得所有的键值对啊? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 取所有的键: HashMap hm = new HashMap(); hm.put("A_thlsd,,", "01"); hm.put("b_adhd", "02"); hm.put("c_decteln", "03"); hm.put("d_apple", "04"); hm.put("e_blue", "05"); hm.put("ff_drag", "06"); hm.put("g_cellention", "07"); Set set = hm.keySet(); Object[] obj=set.toArray(); Arrays.sort(obj); for(int i=0;i<obj.length;i++){ System.out.println(obj[i]); }取所有的键值: HashMap hm = new HashMap(); hm.put("A_thlsd,,", "01"); hm.put("b_adhd", "02"); hm.put("c_decteln", "03"); hm.put("d_apple", "04"); hm.put("e_blue", "05"); hm.put("ff_drag", "06"); hm.put("g_cellention", "07"); Set set = hm.entrySet(); Object[] obj=set.toArray(); //Arrays.sort(obj); for(int i=0;i<obj.length;i++){ System.out.println(obj[i]); } HashMap hp = new HashMap(); hp.put("a", "1"); hp.put("b", "1"); Iterator i = hp.keySet().iterator(); while(i.hasNext()) System.out.println(i.next()); 1.Set set = map.keySet();Iterator it = set.iterator();if(it.hasNext()){ Object j = it.next(); System.out.println(j); System.out.println(map.get(j)) ;}2.Set set = map.entrySet();Iterator it = set.iterator();if(it.hasNext()){ Map.Entry me = (Map.Entry) it.next(); System.out.println(me.getKey()); System.out.println(me.getValue());} 一个截取字段问题 一个查询sql JMF 语音视频问题 自己开发了一个CRM,可以免费使用及分发,希望对有需要朋友有帮助! JDialog关闭后出现的问题,郁闷啊!!!! Thinking in java 书中一问? 张孝祥的Java就业培训教程,好动东呀,自己看当然不合适,还是大家一起看吧 struts初学者的苦恼 请问如何在applet实现文件的存储问题?? 如何得到一个模态的JFrame,即弹出新窗口后原窗口无效? 如何用HashMap来统计一个字符串中重复的单词 急需java计算器小程序,在线等!!!!!!!
HashMap hm = new HashMap();
hm.put("A_thlsd,,", "01");
hm.put("b_adhd", "02");
hm.put("c_decteln", "03");
hm.put("d_apple", "04");
hm.put("e_blue", "05");
hm.put("ff_drag", "06");
hm.put("g_cellention", "07");
Set set = hm.keySet();
Object[] obj=set.toArray();
Arrays.sort(obj);
for(int i=0;i<obj.length;i++){
System.out.println(obj[i]);
}
取所有的键值: HashMap hm = new HashMap();
hm.put("A_thlsd,,", "01");
hm.put("b_adhd", "02");
hm.put("c_decteln", "03");
hm.put("d_apple", "04");
hm.put("e_blue", "05");
hm.put("ff_drag", "06");
hm.put("g_cellention", "07");
Set set = hm.entrySet();
Object[] obj=set.toArray();
//Arrays.sort(obj);
for(int i=0;i<obj.length;i++){
System.out.println(obj[i]);
}
hp.put("a", "1");
hp.put("b", "1");
Iterator i = hp.keySet().iterator();
while(i.hasNext())
System.out.println(i.next());
Set set = map.keySet();
Iterator it = set.iterator();
if(it.hasNext()){
Object j = it.next();
System.out.println(j);
System.out.println(map.get(j)) ;
}
2.
Set set = map.entrySet();
Iterator it = set.iterator();
if(it.hasNext()){
Map.Entry me = (Map.Entry) it.next();
System.out.println(me.getKey());
System.out.println(me.getValue());
}