Collections.sort(playerList.get(0).pokers,new TestPoker());
public TestPoker(){
this.playerList=new ArrayList <Player>();
PokerList this.pokerList=new ArrayList<Poker>();
this.pokerListAfterShuffle=new ArrayList<Poker>(); console=new Scanner(System.in);
String[] pokerPoint={"2","3","4","5","6","7","8","9","10","J","Q","K","A"}; String[] pokerColor={"方片","梅花","红桃","黑桃"};
for(String point:pokerPoint){ for(String color:pokerColor){ Poker pk=new Poker(point,color); pokerList.add(pk); } } }
_____________
Collections.sort(playerList.get(0).pokers,new TestPoker()); 这个写在给集合排序的sort里的
new TestPoker()是真的看不懂什么意思,希望大佬跟我说一下
1 回答

zzZerOrz
TA貢獻101條經驗 獲得超28個贊
你那樣寫不會報錯嗎,這個接口public static <T> void sort(List<T> list, Comparator<? super T> c)的第二個參數是個比較器誒
點擊展開后面3條
添加回答
舉報
0/150
提交
取消