plorzzz
2016-12-13 09:40
public void pokerSetUp(){
Poker pokerCard = new Poker();
List pokerList = new ArrayList();
String[] pokerstr1 = {"黑桃","红桃","梅花","方片"};
String[] pokerstr2 = {"2","3","4","5","6","7","8","9","10","J","Q","k"};
System.out.println("----------创建扑克牌----------");
for(int i=0;i < 4;i++){
for(int j=0;j < 12;j++){
pokerCard.pokercard1 = pokerstr1[i];
// System.out.println(pokerstr1[i]);
// System.out.println(pokerCard.pokercard1);
pokerCard.pokercard2 = pokerstr2[j];
// System.out.println(pokerstr2[j]);
// System.out.println(pokerCard.pokercard2);
pokerList.add(pokerCard);
}
}
System.out.println("----------扑克牌创建成功----------");
System.out.println("为:");
/**
* 通过For each访问List
*/
for (Object obj : pokerList) {
Poker cr = (Poker) obj;
System.out.print(cr.pokercard1 + cr.pokercard2 + " ");
}
}
存错了,取错了
// System.out.println(pokerstr1[i]);
// System.out.println(pokerCard.pokercard1);
测试发现在输入List之前我的每个元素都是正确的 但是使用add在循环中添加后用For each遍历输出出来全是 方片k
头疼 56个方片k ....
Java入门第三季
409792 学习 · 4340 问题
相似问题