HomeTagSubmit NotesAsk AnythingLoginSubscribe Us
1. Feel Free to ask and submit anything on and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
3. Our Experts are looking for yours ?.

corejava-exception-handling: How to handle NullPointerException?

how can we handle NullPointerException in java?

corejava x 353
exception-handling x 24
Posted On : 2016-03-16 22:50:44.0
profile sudhir kumar - sudhir kumar


NullPointerException is an unchecked exception and extends RuntimeException. It doesn´t force you to use catch block to handle it. NullPointerException is thrown when an application attempts to use an object reference, having the null value. This may include:

1. Calling an instance method on the object referred by a null reference.
2. Accessing or modifying an instance field of the object referred by a null reference.
3. If the reference type is an array type, taking the length of a null reference.
4. If the reference type is an array type, accessing or modifying the slots of a null reference.
5. If the reference type is a subtype of Throwable, throwing a null reference.
6. Applications should throw instances of this class to indicate other illegal uses of the null object.

For more information Handling NullPointer Exception- Click Here

Posted On : 2016-03-17 00:14:56
Satisfied : 1 Yes  0 No
profile Rishi Kumar - Rishi Kumar
Reply This Thread

Post Answer
Please Login First to Post Answer: Login login with facebook -