I would like to know concept behined this one....
public class example {
int i[] = {0};
public static void main(String args[]) {
int i[] = {1};
change_i(i);
System.out.println(i[0]);
}
public static void change_i(int i[]) {
int j[] = {2};
i = j;
}
}
The program does not compile.
The program prints 0.
The program prints 1.
The program prints 2.
The program prints 4.
answer is

rogram prints 1
one more question
public class example {
int i = 0;
public static void main(String args[]) {
int i = 1;
change_i(i);
System.out.println(i);
}
public static void change_i(int i) {
i = 2;
i *= 2;
}
}
The program does not compile.
The program prints 0.
The program prints 1.
The program prints 2.
The program prints 4.
answer is

rogram prints 1
one more please
public class example {
int i[] = {0};
public static void main(String args[]) {
int i[] = {1};
change_i(i);
System.out.println(i[0]);
}
public static void change_i(int i[]) {
i[0] = 2;
i[0] *= 2;
}
}
The program does not compile.
The program prints 0.
The program prints 1.
The program prints 2.
The program prints 4.
answer is

rogram prints 4
let me know about the logic please
thanks in advance