Nkumawat Nkumawat - 4 months ago 43
Java Question

NullPointerException and NullReferenceException

What is the difference between NullPointerException and NullReferenceException?

Answer

NullPointerException - The Java exception thrown when an application attempts to use null in a case where an object is required.

NullReferenceException - The exception that is thrown when there is an attempt to reference (or use) a null or uninitialized object.

There is no 'NullReferenceException' in Java. Java has an equivalent class 'NullPointerException'.