1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
   |  package lianxi;
  import java.util.*; import java.io.*;
  public class lianxix { 	public static void main(String[] args) { 		HashMap<String, String> map = new HashMap<String, String>(); 		map.put("yusijia", "dabai"); 		map.put("wutongyu", "datong"); 		map.put("tong", "bai"); 		System.out.println(map); 		System.out.println("datong is in the map? " + map.containsKey("wutongyu")); 		map.remove("tong"); 		System.out.println(map); 		 		 		Iterator it = map.keySet().iterator(); 		while(it.hasNext()){ 			String key = (String)it.next(); 			System.out.println("key: " + key); 			System.out.println("value: " + map.get(key)); 			System.out.println("The hashCode of value: " + map.get(key).hashCode()); 		} 		System.out.println(map.size()); 		 		 		Iterator it2 = map.values().iterator(); 		while(it2.hasNext()){ 			String vaule = (String)it2.next(); 			System.out.println(vaule); 		} 	} }
 
  |