Java NullPointerException. Why?

Posted by user292844 on Stack Overflow See other posts from Stack Overflow or by user292844
Published on 2010-03-13T07:13:32Z Indexed on 2010/03/13 7:25 UTC
Read the original article Hit count: 226

Filed under:
|

I am new to Java. I just read that class variables in Java have default value. I tried the following program. I 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());
}

}

© Stack Overflow or respective owner

Related posts about java

Related posts about beginner