Java HashMap 遍历 练习
protected void HSM() {
Map<String, String> x = new HashMap<String, String>();
x.put("a", "aa");
x.put("b", "bb");
x.put("c", "cc");
x.put("d", "dd");
System.out.println(x);
System.out.println("1111111111111111");
Set<String> setk = x.keySet();
Iterator ite = setk.iterator();
while (ite.hasNext()) {
String temp = (String) ite.next();
System.out.println(temp);
System.out.println(x.get(temp));
}
System.out.println("22222222222222");
for (String String : setk) {
System.out.println(String);
System.out.println(x.get(String));
}
}
0 件のコメント:
コメントを投稿