Buy a deck of cards string[] num = {"3", "4", "5", "6", "7", "8", "9", "Ten", "J", "Q", "K", "A", "2"}; string[] color = {"Square slice", "Plum Blossom", "Red Peach", "spades"}; Hashmap<integer, string> HM = new hashmap<> (); Storage index and poker arraylist<integer> list = new arraylist<> (); Store index int index = 0; The starting value of the index for (string s1:num) {for (string s2:color) {hm.put (index, S2.concat (S1)); Add index and poker to HashMap list.add (index); Adds an index to the ArrayList collection index++; }} hm.put (Index, "Xiao Wang"); List.add (index); index++; Hm.put (Index, "King"); List.add (index); Shuffle collections.shuffle (list); Licensing treeset<integer> Gaojin = new treeset<> (); treeset<integer> Longwu = new treeset<> (); treeset<integer> me = new treeset<> (); treeset<integer> Dipai = new treeset<> (); for (int i = 0; i < List.size (); i++) {if (I >= list.size ()-3) {Dipai.add (List.get (i)); Adding an index from the list collection to the TreeSet collection automatically sorts}else if (i% 3 = = 0) {Gaojin.add (List.get (i)); }else if (i% 3 = = 1) {Longwu.add (List.get (i)); }else {me.add (List.get (i)); }}//See card Lookpoker ("Gao Jin", Gaojin, HM); Lookpoker ("Dragon Five", Longwu, HM); Lookpoker ("Feng Jia", Me, HM); Lookpoker ("Hole cards", Dipai, HM);} public static void Lookpoker (String name,treeset<integer> Ts,hashmap<integer, string> HM) {System.out.prin T (name + "The card is:"); for (Integer index:ts) {System.out.print (Hm.get (index) + ""); } System.out.println ();}