我有這個用戶類我如何分類我的Arraylist?
public class User {
public String userName;
public int highScore = 0;
public static ArrayList<User> userList = new ArrayList<User>(5);
public User(String name, int score) {
this.userName = name;
this.highScore = score;
userList.add(this);
Collections.sort(userList, new Comparator<User>() {
@Override
public int compare(User lhs, User rhs) {
return lhs.highScore-rhs.highScore;
}
});
}
}
用戶對象具有的屬性名稱和score.i要排序我的用戶評分的基礎上名單。
請標記您的問題,用適當的語言。 – meagar 2013-02-22 14:52:48