import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
public class TreeMapDemo1 {
public static void main(String[] args) {
TreeMap<String, String >treeMap=new TreeMap<String ,String >();
treeMap.put("jack", "zhangsan");
treeMap.put("mary", "xiaoming");
treeMap.put("rose", "xiaohong");//小红被小华替换
treeMap.put("free", "xiaogang");
treeMap.put("rose", "xiaohua");
System.out.println(treeMap);
//输出时按照键的顺序输出
Set<Entry<String, String>>temp=treeMap.entrySet();
for (Entry<String, String> entry : temp) {
System.out.println(entry.getKey()+">>>"+entry.getValue());
}
}
}