TreeMap 的实现就是红黑树数据结构,也就说是一棵自平衡的排序二叉树
import java.util.TreeMap;
public class TreeMapTest {
public static void main(String args[]){
TreeMap<String,Double>temp=new TreeMap<String,Double>();
temp.put("b", 12.0);
temp.put("v", 11.0);
temp.put("c", 13.0);
temp.put("d", 16.0);
temp.put("e", 14.0);
System.out.println(temp.toString());
}
}
输出:{b=12.0, c=13.0, d=16.0, e=14.0, v=11.0}
也就是说是按key排序的。