package chapter6;

import java.util.Iterator;
import java.util.Set;
import java.util.TreeMap;

public class Example19 {
    public static void main(String[] args) {
        TreeMap map = new TreeMap();      // 创建Map集合
        map.put(3, "李四");               // 存储键和值
        map.put(2, "王五");
        map.put(4, "赵六");
        map.put(3, "张三");

        Set keySet = map.keySet();
        Iterator iterator = keySet.iterator();
        while (iterator.hasNext()) {
            Object key = iterator.next();
            Object value = map.get(key);
            System.out.println(key + ":" + value);
        }
    }
}
