TreeMap
排序如何?例如,您有以下地图:
TreeMap<String, Integer> treemap = new TreeMap<>();
treemap.put("lol", 1);
treemap.put("Marc", 2);
treemap.put("Jesper", 3);
Iterator ittwo = treemap.entrySet().iterator();
while (ittwo.hasNext()) {
Map.Entry pairs = (Map.Entry)ittwo.next();
System.out.println(pairs.getKey() + " = " + pairs.getValue());
ittwo.remove();
}
这个的输出是:
Jesper = 3
Marc = 2
lol = 1
因此,如果它不是按字母顺序排列的,那么它是什么?