for(Enumeration enum = e.keys();enum.hasMoreElements();){
Object keyObj;
keyObj = (Object)enum.nextElement();
Object valueObj;
valueObj = e.get(keyObj);
System.out.println(keyObj + " = " +valueObj);
}
Object keyObj;
keyObj = (Object)enum.nextElement();
Object valueObj;
valueObj = e.get(keyObj);
System.out.println(keyObj + " = " +valueObj);
}
解决方案 »
- JAVA数据结构
- 实在没想到啥招获取上一个元素的背景色。JList中使用ListCellRenderer为元素附背景色,怎样获取上面元素的背景色啊
- 关于Map的键的问题
- 数组不是对象
- 时钟日历代码的几个疑问搞不懂
- 关于JAVA中连接数据库查询
- 请问EClipse和JCreator相比,有什么优点么?
- 请问各位,JAVA开发所用的操作系统是什么?WIN98,WIN2000,WIN-XP,LINUX or UNIX?
- java 多态问题
- java抽象类,接口,三大特征,this关键字,方法调用的综合应用
- 如何识别一个已经在画板上画好的图形,并用鼠标选定它,然后拖拽到一个新的位置
- sharetop(天生不笨) 请进 . (hexiaofeng)
element to a hashtable ht as :-ht.putValue("My Message","Hello World!);My message is the key here. You can search for by doingString searchResult = (String) ht.getValue("My Message");your searchResult will have the string "Hello World".so the key in yours is 1 2 3
the searchResult will be the string " a b c "
up 後會到最前面!
--
Hashtable ht = new Hashtable();
ht.put("1", "a");
ht.put("2", "b");
ht.put("3", "c"); int len, i;
len = ht.size();
i = 0; String[] keys = new String[len];
Enumeration e = ht.keys(); while (e.hasMoreElements()) {
keys[i++] = (String)e.nextElement();
}
Arrays.sort(keys); String[] values = new String[len]; for (i=0; i<len; i++) {
values[i] = (String)ht.get(keys[i]); System.out.println(keys[i] + "=" + values[i]);
}
--