import java.util.*;
public class hehe {
public static void main(String args[]){
Map<String ,String> map = new HashMap<String,String>();
map.put("1","111");
map.put("2","222");
map.put("3","333");
/* 方法一:KeySet*/
System.out.println("方法一");
System.out.println(map.keySet());
Set M = map.keySet();
Iterator it = M.iterator();
while(it.hasNext()){
String str =(String) it.next();
System.out.println(str + " "+map.get(str) );
}
/* 方法二:entrySet*/
System.out.println("方法二");
System.out.println(map.entrySet());
it = map.entrySet().iterator();
while(it.hasNext()){//entrySet的返回类型为Map.Entry
Map.Entry my = (Map.Entry) it.next();
System.out.println(my.getKey()+" "+ my.getValue());
}
/*方法三:*/
System.out.println("方法三");
for(String i : map.values()){
System.out.println(i);
}
}
}