小编Coo*_*ght的帖子

在Java Array <> libgdx中需要帮助

在将数组<>项分配给临时变量后更改其值时,主变量值也会更改.

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制作游戏.

java libgdx

1
推荐指数
1
解决办法
404
查看次数

标签 统计

java ×1

libgdx ×1