If I create a duplicate array like this in java is it correct ?
int [] array = { 10, 20 , 5 , 67 , 4} ;
int [] d_array = array ;
If I create a duplicate array like this in java is it correct ?
int [] array = { 10, 20 , 5 , 67 , 4} ;
int [] d_array = array ;
That's not creating a duplicate array. That's creating a new reference to an existing array. Modifying one will modify "both".
You want to look into the System.arrayCopy() method to create a new copied instance of some array.
See Kon's answer. Try this:
int [] array = new int[]{ 10, 20 , 5 , 67 , 4} ;
int [] d_array = array.clone();
Now there are to different references
in this case if you change any item in the first array it will be changed in the second, for example if you write:
array[0] = 5;
then also d_array[0] will become 5
to copy an array without having the same reference, replace:
int [] d_array = array ;
with
int [] d_array = array.clone();