在将数组<>项分配给临时变量后更改其值时,主变量值也会更改.
Array<Cards> cards = new Array<Cards>();
//add items to cards
Iterator<Cards> iterator = cards.iterator();
while(iterator.hasNext()){
Cards c = iterator.next();
Cards Temp = c;
//when I change values of temp...the value of c also changes
//overall changing the value of cards
}
Run Code Online (Sandbox Code Playgroud)
有什么方法可以改变Temp的价值而不是c或卡吗?
我目前正在用libgdx为Android制作游戏.