I have a array int[3][3] with this initial position:
(A)
block[0][0] = 1;
block[0][1] = 1;
block[0][2] = 1;
block[1][0] = 1;
block[1][1] = 1;
block[1][2] = 1;
block[2][0] = 1;
block[2][1] = 0;
block[2][2] = 1;
//Visually
1 1 1
1 1 1
1 0 1
I have a method that takes the "0" element and change with the upper element, so the next state is:
(B)
1 1 1
1 0 1
1 1 1
But the problem is, I want to create a NEW array (called aux) with this positions and DO NOT OVERIDE the block array (A)
Here is my code:
//Creating array B
int[][] aux = new int[3][3];
aux = block; //load the values of original array
aux[line][row] = aux[line-1][row];
aux[line-1][row] = 0;
But when I check the ouput, I have also overridden the original array (block).
So I have the array BLOCK and the array AUX with the same values, and DO NOT kept the array BLOCK with the original data.
===========================================================================
EDIT:
I tried to use the clone and copyOf functions, but the result also affected the original array. Here is my code:
System.out.println("INITIAL BLOCK VALUES");
            System.out.println(
                            bloco[0][0] +""+
                            bloco[0][1] +""+
                            bloco[0][2] +
                            "\n"+
                            bloco[1][0]+
                            bloco[1][1]+
                            bloco[1][2]+
                            "\n"+
                            bloco[2][0] +
                            bloco[2][1] +
                            bloco[2][2]
                    );
            //Cloning original array to a new one
            int[][] aux = bloco.clone();
            //Here what I'm doing is changing the first element of AUX, just for test
            aux[0][0] = 9;
            // Block array shouldnt be affected! Lets check it out:
            System.out.println("FINAL BLOCK VALUES");
            System.out.println(
                                    bloco[0][0] +""+
                            bloco[0][1] +""+
                            bloco[0][2] +
                            "\n"+
                            bloco[1][0]+
                            bloco[1][1]+
                            bloco[1][2]+
                            "\n"+
                            bloco[2][0] +
                            bloco[2][1] +
                            bloco[2][2]
                    );
And the OUPUT is:
INITIAL BLOCK VALUES
111
111
101
FINAL BLOCK VALUES
911
111
101
any thoughts?
OBS: This code is inside a function of a class called "Node" which contructor is:
public Nodo( int[][] blocos )
        {
            this.bloco = blocos;
        }
 
    