class Boxing2 {
static Integer x;
public static void main(String[] args) {
doStuff(x);
}
static void doStuff(int z) {
int z2 = 5;
System.out.println(z2 + z);
}
}
This code compiles fine, but the JVM throws a NullPointerException
Exception in thread "main" java.lang.NullPointerException at Boxing2.main(Test.java:4)
I cannot figure out the reason of this.