public class Q3 {
public static void doSomething(int [] x, int[] y) {
for (int i = 0; i < x.length; i += 2) {
x[i] = y[i];
}
y = x;
}
public static void main(String[] args) {
int [] x = {2, 4, 6, 8};
int [] y = {0, 1, 2, 3};
doSomething(x, y);
System.out.println(x[0] + "," + x[1] + "," + x[2] + "," + x[3] );
System.out.println(y[0] + "," + y[1] + "," + y[2] + "," + y[3] );
}
}
- this is a question about array function why answer is 0,4,2,8/n 0,1,2,3 rather than 0,4,2,8/n 0,4,2,8