//從大的角度能夠分爲兩類Set<String> set=map.keySet();這裏面還能夠分爲3類, 從set的角度來分code
//Set<Map.Entry<String, String>> entery=map.entrySet();get
public class Test {class
public static void main(String[] args) { Map<String,String> map=new HashMap<String,String>(); System.out.println(map.put("s", "mao")); System.out.println(map.put("sm", "mao")); Set<String> set=map.keySet(); for(String s:set) System.out.println(s+":"+map.get(s)); Set<Map.Entry<String, String>> entery=map.entrySet(); for(Entry<String, String> s:entery) { System.out.println(s.getKey()); System.out.println(s.getValue()); } }
}map