Pages

Monday, 9 January 2012

Null Pointer Exception

The most commonly seen exception(in java) for everyone is ofcourse nullpointerexception. In this post we will see how this eception occurs and how to get rid of it.

               As you might know java is a object oriented language if we want to call any method that has to be done by using object reference. So if at all a call to a method which is refering to null will throw a null pointer exception
           for example
     ArrayList list=null;
    list.add("hai");
 will throw null pointer exception so when ever you get such kind of exception just go to the line check the object which is calling the method is not refering to null.

No comments:

Post a Comment