Skip to content
目录概览

请简述TreeSet是如何保证元素唯一性与排序的?

  1. 实现自然排序接口 Comparable,重写 compareTo(T t)方法
  2. 实现比较器排序接口 Comparator,重写 compare(T t1, T t2)方法