Copying array values without creating just a reference.
How do you copy the values of one array to another without the 2nd array just being a reference to the first? I need to be able to copy an array and modify the original without those modifications getting passed to the copy.
here's my code
Code:
// there's a matrix of Doubles called columns: the one I want to copy
for (int i = 0; i < rowlength ; i++) {
for (int e = 0; e < rowlength ; e++) {
//copy
Double d= new Double(columns[i][e]);
prevcolumns[i][e]=new Double(d.doubleValue());
}
}
for (int i = 0; i < size; i++) {
for (int e = 0; e < size; e++) {
columns[30 + i][30 + e] += 1;
}
}
// for any columns[i][e] it is the same as prevcolumns[i][e]... which is bad
thanks for any thoughts