我想为Comparator
a使用自定义TreeMultiSet
。这就是我所做的:
public static class OccurenceComparator implements Comparator<Multiset.Entry<String>>{
@Override
public int compare(Multiset.Entry<String> e1, Multiset.Entry<String> e2) {
return e2.getCount() - e1.getCount() ;
}
}
public static void main(String args[]) throws Exception{
Comparator<Multiset.Entry<String>> occurenceComparator = new OccurenceComparator();
Multiset<String> treeMultiSet = TreeMultiset.create(occurenceComparator);
}
这是我得到的:
未解决的编译问题:
create(Comparator<? super E>)
类型TreeMultiset
中的方法不适用于参数(Comparator<Multiset.Entry<String>>)
我很难过