I'm doing an algorithm in like this:
public int[][] moveLeft(int m[][], int[] index){
Puzzle x = new Puzzle(m);
System.out.println(x);
int[][] p = m;
int temp = p[index[0]][index[1]];
p[index[0]][index[1]] = p[index[0]][index[1]-1];
p[index[0]][index[1]-1] = temp;
return p;
}
To be more specific, what i'm trying to do is to change the position of certain values and return the new matrix, but when i'm debuging, i noted that the value "m" also changues, even when im doing changes to the value p. What is wrong here?