Codenameone 代码名一:使用Integer/int方法编写排序比较
Codename One不接受基元类型(int),因此我尝试使用Integer编写以下比较器:Codenameone 代码名一:使用Integer/int方法编写排序比较,codenameone,Codenameone,Codename One不接受基元类型(int),因此我尝试使用Integer编写以下比较器: private static class CelebrityPopularityComparator implements Comparator<Celebrity> { @Override public int compare(Celebrity celebrity1, Celebrity celebrity2) { Integer celebrity1P
private static class CelebrityPopularityComparator implements Comparator<Celebrity> {
@Override
public int compare(Celebrity celebrity1, Celebrity celebrity2) {
Integer celebrity1PopularitySum = celebrity1.getCelebrityPopularitySum();
Integer celebrity2PopularitySum = celebrity2.getCelebrityPopularitySum();
Integer comparisonResult = Integer.valueOf(celebrity1PopularitySum.compareTo(celebrity2PopularitySum));
return comparisonResult;
}
}
私有静态类CelebrityPopularityComparator实现Comparator{
@凌驾
公共int比较(名人庆典1、名人庆典2){
整数CelebrityPopularitySum=celebrity1.getCelebrityPopularitySum();
整数CelebrityPopularitySum=celebrity2.getCelebrityPopularitySum();
整数比较结果=Integer.valueOf(CellerityPopularitySum.compareTo(CellerityPopularitySum));
返回比较结果;
}
}
我尝试了很多方法,但都不管用。它不会将生成发送到服务器。我能做些什么来修复它?谢谢 试试这个:
Integer celebrity1PopularitySum = celebrity1.getCelebrityPopularitySum();
Integer celebrity2PopularitySum = celebrity2.getCelebrityPopularitySum();
if(celebrity1PopularitySum.equals(celebrity2PopularitySum)){
return 0;
}else if(celebrity1PopularitySum.intValue() < celebrity2PopularitySum.intValue()){
return -1;
}else{
return 1;
}
Integer CellerityPopularitySum=Cellerity1.GetCellerityPopularitySum();
整数CelebrityPopularitySum=celebrity2.getCelebrityPopularitySum();
如果(CellerityPopularitySum.等于(CellerityPopularitySum)){
返回0;
}else if(CelebrityPopularitySum.intValue()