Java NullPointException - How/when NullPointerException throws

-: Java.lang.NullPointerException :-

java.lang.NullPointerException is one the frequently getting exception in java. Most of the developer must have seen this exception while developing either java standalone application or web-based application.

1.      Hierarchy


Basically, exceptions occur at compile time and runtime. The NullPointerException is a runtime exception. Mainly this exception occurs when trying to do some operation on null where an object is required but it is null. Some of the common reasons for NullPointerException in Java programs are described below section.
2.       Common reasons for NullPointerException:
a.       Invoking a method on an object instance but an object is null at runtime.
b.       Access the variables of an object that is null at runtime.
c.       Throwing null in the java program.
d.       Accessing the index of an array which is null.
e.       Checking the length of the array that is null at runtime.

f.        When the method argument passed value.

........(to be continues)

Java Exceptions

Java NullPointException - How/when NullPointerException throws

-: Java.lang.NullPointerException :- java.lang.NullPointerException is one the frequently getting exception in java. Most of the devel...