Thursday, 15 August 2013

Should I always not catch NullPointerException?

Should I always not catch NullPointerException?

Effective java recommend that we shouldn't catch NullPointerException. Is
it always right?
In many cases of catching NullPointerException, catch body only calls
printStackTrace().
If I don't catch NullPointerException and call printStackTrace(), how I
can check the place where the exception occurred?
And also if I catch NullPointerException and the catch body is empty, we
cannot get any stack information at that time, can we?

No comments:

Post a Comment