Posted on 2006-11-05 17:44
苑 阅读(304)
评论(0) 编辑 收藏 所属分类:
java基础学习系列
import
java.util.HashMap;
import
java.util.Iterator;
import
java.util.Map;
public class
MainClass
{
public static
void
main
(
String
[]
argv
) {
Map map =
new
HashMap
()
;
map.put
(
"Adobe"
,
"Mountain View, CA"
)
;
map.put
(
"IBM"
,
"White Plains, NY"
)
;
map.put
(
"Learning Tree"
,
"Los Angeles, CA"
)
;
Iterator k = map.keySet
()
.iterator
()
;
while
(
k.hasNext
()) {
String key =
(
String
)
k.next
()
;
System.out.println
(
"Key "
+ key +
"; Value "
+
(
String
)
map.get
(
key
))
;
}
}
}