static int[] array = new int[1];
static int fun() {
array = new int[10];
return 3;
}
public static void main(String[] args) {
array[fun()] = 2;
}
Why does the above code give ArrayIndexOutOfBoundsException while:
public static void main(String[] args) {
fun();
array[3] = 2;
}
does not!
Thanks.