Im a beginner programmer and i want to make a copy function that clones an array in to another one, for example: if i have this array already declared [1,2,3,4,5] i want the function to clone that array. Here is my code but when compiling im obtaining the array address. By the way im not programming with objects yet.
static int[] copy(int[] collection) {
int result[] = new int [collection.length];
for(int i = 0; i<collection.length; i++) {
result[i]=collection[i];
}
return result;
}
if i print it like this i obtain the address, something like "[I@76ccd017"
public static void main(String[] args){
int[] nums = {1,2,3,4,5};
System.out.println(copy(nums));
}