public class TestBox {
Integer i;
int j;
public static void main (String[] args) {
TestBox t = new TestBox();
t.go();
}
public void go() {
j = i;
System.out.println(j);
System.out.println(i);
}
}
I get a null pointer exception on line j=i
.
Although if this line is transformed as i=j
i get the out put as 0 0
which is the default values of int.
My question is, when i
is assigned to j
, shouldn't i
get unboxed as an int variable and take the default value of 0 instead of its original default null ?