public class TreeMapTest { public static void main(String[] args) { Map<Student,Integer> students = new TreeMap<>(); students.put(new Student("11"),1); students.put(new Student("11"),1); System.out.println(students.size());…
假设现在有一个学生类 class Student { int age; public Student(int age) { this.age = age; } } 要使学生类之间能进行比较,实现System.IComparable接口的CompareTo方法 class Student : System.IComparable { int age; public Student(int age) { this.age = age; } public int CompareTo(object ob…