NullPointerException

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());
    }
}
NullPointerException in Java

Similar Java Tutorials

Leave a Comment