top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

How to handle nullpointer exception in java?

+1 vote
59 views
How to handle nullpointer exception in java?
posted Oct 3, 2013 by Nagarajuk

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Try catching it

catch (NullPointerException npe) {
            npe.printStackTrace();
}

or

catch (IOException | NullPointerException npe) // you can multi-catch exceptions, java7 new feature
   npe.printStackTrace();
}    

Now the point is try to avoid this situation please go through this link
http://howtodoinjava.com/2013/04/05/how-to-effectively-handle-nullpointerexception-in-java/

answer Oct 3, 2013 by Salil Agrawal
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...