Why Java changes my variables..?
Hello everybody,
I am one of the new comers to Java....
I have faced a stupid problem. I am implementing some genetic algorithm in Java. In one part I save a 1-D array that is a member of a bigger 2-D array in another array. Then I need to make some changes in this big 2-D array, but these changes should not affect the thing that I have stored before in somewhere else, BUT it affects!!!
To make the situation more clear, look at this example:
...
Solution[i] = pop[0][i];
.....
pop[0] = Mutate(pop[0],pop[1]);
......
Now if I read Solution[], it should be the thing that I have stored before, but the changes in pop exactly affect this Solution array....
Could someone please tell me why this happens?