I am new to Java. I just read that class variables in Java have default value.
I tried the following program and was expecting to get the output as 0
, which is the default value on an integer, but I get the NullPointerException
.
What am I missing?
class Test{
static Integer iVar;
public static void main(String...args) {
System.out.println(iVar.intValue());
}
}