JDK 1.4 the NullPointerException - Java Tutorials

JDK 1 4 NullPointerException

JDK 1 4 NullPointerException

NullPointerException In Java

NullPointerException occurs when you perform an operation on a
object or calling a method on the object. The only way to solve Null
Pointer Exception is to avoid executing operation on a object or calling a
method on the object.

Code Description

In the above class we have declared a String array which has size 2. But we
haven't initialize the array therefore at position 1 there is nothing. So When
we call charAt() function, the above code throw
NullPointerException.