class Comparator1 implements Comparator<Foo> 现在,我在我的类Bar中使用Foo对象的TreeSet。class Bar private SortedSet<Foo> foos = new TreeSet(new Comparator1()); 在xml映射中
如下所示:https://docs.oracle.com/javase/8/docs/api/java/util/TreeSet.html TreeSet类中有两个构造函数: TreeSet(Collectionextends E> c)
TreeSet(Comparator<?super E> comparator) 我不确定上面2中的哪个构造函数与下面的t2 TreeS
我需要为InetSocketAddress编写Comparator,这样才能在TreeSet中使用这个类。它们需要按地址和端口进行比较。代码看起来像这样,但问题是我不知道如何通过<(-1),>(1),=(0)比较地址和端口 (new Comparator<InetSocketAddress>() {
publ