java静态代码块之扑克牌

静态代码块生成54张扑克牌

 

package cn.edu.dcxy;

import java.util.ArrayList;

public class StaticCards {
    public static ArrayList<String> cards = new ArrayList<String>();

    static {
        String[] sizes = {"3","4","5","6","7","8","9","10","J","Q","K","1","2"};
        String[] colors = {"♥","♠","♣","♦"};

        for (int i = 0; i < sizes.length; i++) {
            for (int j = 0; j < colors.length; j++) {
                String card = sizes[i]+colors[j];
                cards.add(card);
            }
        }
        cards.add("小🃏");
        cards.add("大🃏");
        System.out.println("新牌:"+cards);
    }

    public static void main(String[] args) {
    }
}

  

新牌:[3♥, 3♠, 3♣, 3♦, 4♥, 4♠, 4♣, 4♦, 5♥, 5♠, 5♣, 5♦, 6♥, 6♠, 6♣, 6♦, 7♥, 7♠, 7♣, 7♦, 8♥, 8♠, 8♣, 8♦, 9♥, 9♠, 9♣, 9♦, 10♥, 10♠, 10♣, 10♦, J♥, J♠, J♣, J♦, Q♥, Q♠, Q♣, Q♦, K♥, K♠, K♣, K♦, 1♥, 1♠, 1♣, 1♦, 2♥, 2♠, 2♣, 2♦, 小🃏, 大🃏]

  

posted @ 2022-11-21 18:09  宝山方圆  阅读(28)  评论(0编辑  收藏  举报