What is null pointer exception in Java and how to fix it?
A null pointer exception is thrown Whenever you try to
- Call the instance method of a null object.
- Access, modify, print, a null value.
- Trying to access (print/use in statements) the length of the null value.
- Throw a null value.
- Access an element of an array without initializing it.
Then, a Null Pointer Exception will be thrown.
Published on 10-Jan-2018 13:13:55