I'm trying to make a swap operation. But when i tried to swap, it changes temp and the orginal array. The codes are here.
private int[] currentNumbers;
currentNumbers = new int[7] { 0, 1, 2, 3, 4, 5, 6 };
public int[] getNumbers()
{
return currentNumbers;
}
int[] temp;
int[] ux = numbers.getNumbers();
int i=1, j=2;
temp = swap(i, j, ux);
public int[] swap(int i,int j,int[] u) {
int t = u[i];
u[i] = u[j];
u[j] = t;
return u;
}
That code blocks changed ux array as planned. But changed currentNumbers. I don't want swap in orginal array. What can i do about that? Any ideas?