NullPointerException is a child class of RunTimeException, Hence it is an unchecked exception, Raised automatically by JVM, Whenever we are trying to perform any operation on null we will get this NullPointerException.
public class NullPointerException {
public static void main(String[] args) {
String str = null;
System.out.println(str.length());
}
}
Similar Java Tutorials
- Odd Even in Java
- Method to print exception information in Java
- Exception Handling by Using try-catch in Java
- Checked Exception vs Unchecked Exception
- Exception Hierarchy in Java
- Java Exception Handling Interview Questions
- final finally finalize in java
- User Defined Exception in Java
- Exception Handling Keyword in Java
- throw throws in Java
- try with multiple catch block in Java