Question: I'm working with two-dimensional array-values that should be inserted into a ArrayList. But this is done in a for-loop and the value of the two-dimensional array-value gets changed as the loop runs since it is just used as an temp-variable (which makes all of the variables stored in the ArrayList gets changed as this variable changes).
So if I try to print out the content of the ArrayList when the loop is done all the values are the same.

```
    for(int i = 0; i <= Counter; i++)
    {

        if(Xhavetomove >= i)
            arrayvalue[0][0] = this.Xspeed;
        else
            arrayvalue[0][0] = 0;

        if(Yhavetomove >= i)
            arrayvalue[0][1] = this.Xspeed;
        else
            arrayvalue[0][1] = 1;

        System.out.println(arrayvalue[0][1]);
        Object.movement.add(arrayvalue); 
    }

```

Are there anyway I can make it store the value itself?

For example: The first time the loop runs the value is "5,5" but if I print out the ArrayList when the loop is done all the values has turned into "5,1".

Answer: 
At the end each add needs to create an own object.

To use **clone** is one way.

Or to add always the values in pairs, in an other.

A totally different way is to use serialization. This make sense when you do not want to calculate this values but to log it. In this case you need an outputStream

What is best is defined by what you want to do with Object.movement
You need to use array's `clone()` method to make its copy:

```
//for example
int[][] copy = (int[][])arraySource.clone();

```