I tried to make an independent copy of an array but couldnt get one. see i cannot copy it integer by integer using a for loop because of efficiency reasons. Is there any oth
Try using clone () method for this purpose. As I remember this is the only case where Josh Bloch in Effective Java recommended to use cloning.
int[] temp = arr.clone ();
But arrayCopy is much faster. Sample performance test on array of 3,000,000 elements:
System.arrayCopy time: 8ms
arr.clone() time: 29ms
Arrays.copyOf() time: 49ms
simple for-loop time: 75ms