我正在尝试使用 Collections.sort() 对 java 中的对象列表进行排序。但我不断收到此错误:类型参数不在其范围内”。有谁知道我该如何解决这个问题?
我的代码
public List<String> fetchNumbersForLeastContacted()
{
List<String> phonenumberList = getUniquePhonenumbers();
List<TopTen> SortList = new ArrayList<TopTen>();
Date now = new Date();
Long milliSeconds = now.getTime();
//Find phone numbers for least contacted
for (String phonenumber : phonenumberList)
{
int outgoingSMS = fetchSMSLogsForPersonToDate(phonenumber, milliSeconds).getOutgoing();
int outgoingCall = fetchCallLogsForPersonToDate(phonenumber, milliSeconds).getOutgoing();
//Calculating the total communication for each phone number
int totalCommunication = outgoingCall + outgoingSMS;
android.util.Log.i("Datamodel", Integer.toString(totalCommunication));
SortList.add(new TopTen(phonenumber, totalCommunication, 0));
}
//This is where I get the error
Collections.sort(SortList);
TopTen.class
public class TopTen {
private String phonenumber;
private int outgoing;
private int incoming;
public TopTen (String phonenumber, int outgoing, int incoming)
{
this.phonenumber = phonenumber;
this.incoming = incoming;
this.outgoing = outgoing;
}
public String getPhonenumber() {
return phonenumber;
}
public void setPhonenumber(String phonenumber) {
this.phonenumber = phonenumber;
}
public int getOutgoing() {
return outgoing;
}
public void setOutgoing(int outgoing) {
this.outgoing = outgoing;
}
public int getIncoming() {
return incoming;
}
public void setIncoming(int incoming) {
this.incoming = incoming;
}}