import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;
public class Main {
static Scanner input = new Scanner(System.in);
public static void main(String[] args) {
//根据key,从小到大输入
Map<Integer, Integer> map = new TreeMap<>();
//倒叙
//Map<Integer, Integer> map = new TreeMap<>(Collections.reverseOrder());
map.put(3,30);
map.put(1,10);
map.put(2,20);
for(Entry<Integer, Integer> i : map.entrySet()) {
System.out.println(i);
}
}
}
TreeMap四种遍历方法:
https://www.cnblogs.com/damoblog/p/9124937.html