# TreeMap
```java
package com.itcast.mr.topN;
import java.util.TreeMap;
public class TreeMapTest {
public static void main(String[] args) {
TreeMap<Integer, String> treeMap = new TreeMap<>();
treeMap.put(1,"hello");
treeMap.put(2,"hello2");
treeMap.put(3,"hello3");
treeMap.put(4,"hello4");
System.out.println("treemap:"+treeMap);
System.out.println("key:"+treeMap.keySet());
System.out.println("values:"+treeMap.values());
}
}
tree.keySet()方法输出键
tree.values()输出键对应的值