<分区>
public static getDeck(ArrayList<Integer> cards) {
for (int total = 1; total !=5; total++) {
for (int suit = 1; suit != 14; suit++) {
cards.add(suit);
}
}
Collections.shuffle(cards); // Randomize the list
return cards;
}
public static void main(String[] args) {
// Create the cards here.
ArrayList<Integer> cards = new ArrayList<>();
cards = getDeck(cards);
}
我希望能够调用函数 getDeck,它将 52 个数字添加到我传递给它的 Arraylist。在这种情况下卡。然后返回此对象并将其设置为卡片。
我得到的错误是这样的。