静态代码块生成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("小 标签:10,java,String,扑克牌,静态,colors,static,cards From: https://www.cnblogs.com/zhzhang/p/16912230.html