compareTo を使用して整数値と double 値を並べ替えることはできますか? 私のシステムでは、プリミティブ型 int で compareTo(int) を呼び出すことができないというエラーが表示されます。何か案は?
コード:
public int compare(Object o1, Object o2) {
Record o1C = (Record)o1;
Record o2C = (Record)o2;
return o1C.getPrice().compareTo(o2C.getPrice());
}
class Record
public class Record {
String name;
int price;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
}