import java.util.*; public class Deal { public static void main(String args[]) { int numHands = Integer.parseInt(args[0]); int cardsPerHand = Integer.parseInt(args[1]); List deck = Deck.newDeck(); Collections.shuffle(deck); if (numHands * cardsPerHand > deck.size()) { System.out.println("Not enough cards."); return; } for (int i=0; i < numHands; i++) System.out.println(deal(deck, cardsPerHand)); } public static ArrayList deal(List deck, int n) { int deckSize = deck.size(); List handView = deck.subList(deckSize-n, deckSize); ArrayList hand = new ArrayList(handView); handView.clear(); return hand; } }