在创建treeset装的对象时compareto是怎么实现自动排序的

2025-02-27 23:26:55
推荐回答(1个)
回答1:

treeset定制排序使用什么设计模式 例: 对加入 TreeSet的Student对象 实现Comparable接口,通过在Student中重写compareTo()方法确定该对象在TreeSet中的排序方式 Student类如下 class Student implements Comparableprivate int age;