Is it standard behavior for this code to throw a NullPointerException?

Posted by Eric on Stack Overflow See other posts from Stack Overflow or by Eric
Published on 2010-05-22T11:32:57Z Indexed on 2010/05/22 11:40 UTC
Read the original article Hit count: 156

I've had a big problem in some library code, which I've pinned down to a single statement:

System.out.println((String) null);

Ok, the code doesn't actually look like that, but it certainly calls println with a null argument. Doing this causes my whole applicaio to throw an unexpected NullPointerException.

In general, should println throw this exception under that circumstance, or is this non-standard behavior due to a poor implementation of the out instance?

© Stack Overflow or respective owner

Related posts about java

Related posts about nullpointerexception