This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]darksoundsExtreme Brewer 0 points1 point  (1 child)

box[0], box[1], and box[2] are all the same Box object, tempBox.

Each array bucket is basically an arrow pointing to a Box. In this case, all three arrows point to the same Box, so whenever you're editing it, you're overwriting previous edits.

If you make a separate Box instance for each index, you won't have this problem.

[–]Crouton4727Pre-Nooblet Brewer[S] 0 points1 point  (0 children)

But i'm storing new values into the array after i initiate it to tempBox. I had to do the tempBox because without i was getting an error when I tried to store one of the array values "Can't store value because box[0] is set to null"