AF
HomeTagSubmit NotesAsk AnythingLoginSubscribe Us
AF
1. Feel Free to ask and submit anything on Anyforum.in 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 - anyforum.in sudhir kumar
1300
up-rate
3
down-rate

Answers


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 - anyforum.in Rishi Kumar
523188249150
Reply This Thread
up-rate
3
down-rate



Post Answer
Please Login First to Post Answer: Login login with facebook - anyforum.in