public class Pukes { public String color; public String number; public List<Pukes> pukes; public List<String>colors; public List<String>numbers; public Pukes(String color,String number){ this.color=color; this.number=number; } public Pukes(){ //this.pukes=new ArrayList<>(); this.colors=new ArrayList<String>(); this.numbers=new ArrayList<String>();} public void colorsAdd(){ colors.add("黑桃"); colors.add("红桃"); colors.add("梅花"); colors.add("方片"); String dd=colors.get(2); System.out.println(dd); } public void numbersAdd(){ numbers=Arrays.asList("2","3","4","5","6","7","8","9","J","Q","K","A"); String cm= numbers.get(0); System.out.println(cm); } public void testPukes(){ List<Pukes> pukes=new ArrayList<>(); for(int i=0;i<52;i++){ String cm=null; String dd=null; int cm1=i%13; cm=numbers.get(cm1); int cm2=i%4; dd=colors.get(cm2); Pukes temp=new Pukes("dd","cm"); pukes.add(temp); } for(Pukes pu:pukes){ System.out.println(pu.color+pu.number); }、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 12 at java.util.Arrays$ArrayList.get(Arrays.java:3841) at com.pkyx.Pukes.testPukes(Pukes.java:44) at com.pkyx.Pukes.main(Pukes.java:64)。。。。。。。。。。。。。。。。。。。。。。。。。。 cm=numbers.get(cm1);这里
添加回答
举报
0/150
提交
取消