I was going through a test on itester.org and found a question which I don't understand:
public class Runner
{
public static Integer i;
public static void main(String[] args)
{
if (i == 42) {
System.out.printf("wow");
}
}
}
I read before, that integer variable is assigned by default 0. Why is it assigned null here?
i == 42, it tries to unbox the int value inibut sinceiis null, you get a NPE.