用TreeMap可解决排序问题,键为字符串,值为字符串的个数。 import java.util.Map; import java.util.Scanner; import java.util.TreeMap; public class Main{ public static void main(String[] args) { Scanner scanner = new Scanner(System.in); Map<String,Integer> map = new TreeMap<String,Integer>(); ...