

























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


























Foo[0] Foo[1]
Foo[N-1]
myFooList
Objects
Objects
data[4] =
29.95;
double[]
data
new
double[10];
fill
array
double[]
prices
data;
clone
double[] prices =
(double[])data.clone();
Question
Write your own version of arraycopy for int arrays
public static void arraycopy(int[] from,int fromstart, int[] to, int tostart, int count) { }
data, i
1, data.length
System.arraycopy(data, i,
data, i
1, data.length
System.arraycopy(data, i,
data, i
1, data.length
System.arraycopy(data, i,
data, i
1, data.length -
i i
i i
data[i] =
x;
data[i] =
x;
data[i] =
x;
data[i] =
x;
Note that : A[i]= A[j] and A[j] = A[i] do not swap content
Exercise: Reverse an array using swaps