package doudizhu; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; public class demo { public static void main(String[]args){ ArrayList<String> cards=new ArrayList<>(); cards.add("color joker"); cards.add("black joker"); String [] str1={"♣","♦","♠","♥"}; String [] str2={"A","2","J","K","Q","9","8","7","6","5","4","3","10"}; for(int i=0;i<4;i++) { for (int j =0; j<str2.length; j++) { cards.add(str1[i]+str2[j]); } } System.out.println(cards.toString()); Collections.shuffle(cards); System.out.println(cards); ArrayList<String> play1=new ArrayList<>(); ArrayList<String> play2=new ArrayList<>(); ArrayList<String> play3=new ArrayList<>(); ArrayList<String> dipai=new ArrayList<>(); for (int i=0;i<cards.size()-3;i++) { if (i % 3 == 0) { play1.add(cards.get(i)); } else if (i % 3 == 1) { play2.add(cards.get(i)); } else { play3.add(cards.get(i)); } } for(int i=51;i<cards.size();i++){ dipai.add(cards.get(i)); } System.out.println(play1.toString()); System.out.println(play2.toString()); System.out.println(play3.toString()); System.out.println(dipai.toString()); }