| Author |
Why Would new Date Cause an Exception
|
Steve Dyke
Ranch Hand
Joined: Nov 16, 2004
Posts: 1254
|
|
Has any one got an idea why the last line of code in my example would cause a NullPointerException?
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32654
|
|
|
I can't see how Date date = new Date() could cause a NullPointerException. Are you sure it's occurring there? The Documentation doesn't say anything about Exceptions.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
It's definitely not that line that's throwing the exception. Can you post the entire stack trace?
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Mike Simmons
Ranch Hand
Joined: Mar 05, 2008
Posts: 2778
|
|
|
Or, if the stack trace really does appear to be pointing at that line, I think you need to double-check whether the class files being executed were really compiled from the same version of the code as what you're looking at. This can result in misleading error messages.
|
 |
 |
|
|
subject: Why Would new Date Cause an Exception
|
|
|