我想使用Collections.sort()對java中的對象列表進行排序。不過,我不斷收到此錯誤:類型參數不中其綁定」有誰知道我怎麼能解決這個問題使用Collections.sort()對對象排序。獲取一個錯誤
我的代碼
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;
}}