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)的第二个参数是个比较器诶
添加回答
举报
0/150
提交
取消