Code is in Java:
int NUM_OF_DRAWS = 6;
int[] x = {256,384, 512, 640, 768, 896};
for(int i = 0; i < NUM_OF_DRAWS;i++)
{
playerHand.get(i).getPosition().setX(x[i]);
playerHand.add(playerDeck.get(i));
System.out.println(playerHand.get(i).getPosition().getX() + " fine");
}
for(int i = 0; i < playerHand.size();i++)
{
System.out.println(playerHand.get(i).getPosition().getX() + " bug");
}
I can't seem to figure out why I print x coordinates the first time, the x coordinates are assigned correctly. But as soon as I break out of the for loop and print it again using a for loop , the x coordinates of all the cards corresponds to the last element of the array.
output:
256.0 fine
384.0 fine
512.0 fine
640.0 fine
768.0 fine
896.0 fine
896.0 bug
896.0 bug
896.0 bug
896.0 bug
896.0 bug
896.0 bug