Why is an Integer variable assigned null by default?

java, null, object, primitive-types

Solution

Any reference type (i.e. any variable whose type is Object or a sub-class of Object) has a default value of null. This includes `Integer`.

The primitive `int`, on the other hand, has a default value of 0.

Problem

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?

Original source