在 realpokeToSelect.add(temp);这句代码中,为何我输出的temp.number一直都是A?
package SPG;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class SimplePokeGame {
public void testcreatpoke(){
List<Poke> temppokeToSelect= new ArrayList<Poke>();
List<Poke> realpokeToSelect= new ArrayList<Poke>();
String[] x={"2","3","4","5","6","7","8","9","10","J","Q","K","A"};
System.out.println("----------创建扑克牌-------------");
Poke[] poke={new Poke("黑桃",""),new Poke("红桃",""),new Poke("梅花",""),new Poke("方块","")};
temppokeToSelect.addAll(Arrays.asList(poke));
Poke temp=new Poke();
for(int i=0;i<4;i++){
temp= temppokeToSelect.get(i);
for(int k=0;k<13;k++){
temp.number=x[k];
System.out.println(temp.number);
System.out.println("扑克牌为:"+temp.color+temp.number);
realpokeToSelect.add(temp);
}
}
Poke a= realpokeToSelect.get(0);
Poke b= realpokeToSelect.get(1);
Poke c= realpokeToSelect.get(2);
System.out.println(a.number+":"+b.number+":"+c.number);
System.out.println("---------扑克牌创建成功------------");
for (Poke poke2 : realpokeToSelect) {
System.out.println("扑克牌为:"+poke2.color+poke2.number);
}
// System.out.println();
}
public static void main(String[] args) {
SimplePokeGame it = new SimplePokeGame();
it.testcreatpoke();
}