import java.util.Hashtable; import java.util.Iterator; import java.util.Map; import java.util.Set; public class TestDemo { public static void main(String[] args) throws Exception { Map<Integer, String> map = new Hashtable<Integer, String>(); map.put(3, "张三"); map.put(null, "无名氏"); map.put(3, "李四"); map.put(1, "王五"); map.put(0, "赵六"); Set<Integer> set = map.keySet() ; Iterator<Integer> iter = set.iterator() ; while (iter.hasNext()) { Integer key = iter.next() ; System.out.println(key + " --> " + map.get(key)); } } }
执行时出错,编译没有错误啊?求指教!
|