请问这段代码为什么会这样输出?
public class PaiTest {
private List<Card> cardList;
public PaiTest(){
this.cardList = new ArrayList<Card>();
}
public void purcard(){
String[] sh= {"方片","黑桃","红桃","梅花"};
for(int i=0;i<4;i++){
Card cars = new Card();
cars.setShape(sh[i]);
for( int j=2;j<13;j++){
System.out.println("j的值:"+j);
cars.setId(j+"");
System.out.println("添加了卡牌:"+cars.getShape()+cars.getId());
cardList.add(cars);
}
}
for(Card card:cardList)
System.out.println("输出卡牌:"+card.getShape()+" "+card.getId());
}
public static void main(String[] args) {
PaiTest pt = new PaiTest();
pt.purcard();
}
}
输出卡牌:方片 12
输出卡牌:方片 12
输出卡牌:方片 12
输出卡牌:方片 12
输出卡牌:方片 12
输出卡牌:方片 12
输出卡牌:方片 12
输出卡牌:方片 12
输出卡牌:方片 12
输出卡牌:方片 12
输出卡牌:方片 12
输出卡牌:黑桃 12
输出卡牌:黑桃 12
输出卡牌:黑桃 12
输出卡牌:黑桃 12
输出卡牌:黑桃 12
输出卡牌:黑桃 12
输出卡牌:黑桃 12
输出卡牌:黑桃 12
输出卡牌:黑桃 12