Assuming I have a 2-D array as follow:
double[][] a={{1,0,0},{0,0,1},{0,1,0}};
I need to use this 'a' in a loop, each time as an input of a method. According to the output of the method, one element of this 2-D array may change. for example:
double [][] new_a=a;
new_a[0][0]=0;
I want to store the new-a in a Hash-map:
HashMap<Integer,double[][]> Store=new HashMap<Integer,double[][]>();
Store.put(size.Store(),new_a);
next time in the loop I need the original 'a' though. I don't know how I can make a copy from 2-D array 'a' in order to use the original one each time in the loop and store the new one in the Hash-map.
When I coded like above it changes the original 'a' as well and when I want to store in 'Store' it replaces new_a for all previous stored arrays.
I wonder if you can help me with this issue? Thanks.