Ad (728x90)

Filled Under: ,

java.lang.nullpointerexception cause and resolution

Exceptions java
Nullpointerexception is a very common exceptions, which used to come into life of developer, troubleshoot and support have got this type of error  approx. on daily basis.
Did anybody used to troubleshoot this type of error and get the exact root cause for it. No, Just fix it by any means. thats it, no here i am trying to finding out a root cause for NullPointerException.

CAUSE: Null in java, Not have any method into it and when we try something like:
String s = null;
if(s.equals(“search anything in null”))
above line will throw a nullpointerexception as null.equals() can not be run. so to avoid this type of scenerio we should always used to avoid null.equals(), by “searching null”.equals(null). In this case result would be same but will never throw you NullPointerException.

Solution: Always use "string".equal(probablenullvariable).

Please let us know in case We have mistakenly forgotten any scenario.

Unknown

Author & Editor

Has laoreet percipitur ad. Vide interesset in mei, no his legimus verterem. Et nostrum imperdiet appellantur usu, mnesarchum referrentur id vim.

0 comments:

Post a Comment

Please write to us here...

 

We are featured contributor on entrepreneurship for many trusted business sites:

  • Copyright © Tekhnologia™ is a registered trademark.
    Designed by Templateism. Hosted on Blogger Templates.