Please take a look at the code below
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;
}
}
1.How can you define another integer array with the same name in the method.
Is it becoz the method is static so the non static code of the class is inaccessible to static part ??
2.why is the o/p 4 ?? Is it becoz a copy of the array reference is passed and not the value of i[0] ??