Exception in thread “main” java.lang.NullPointerException

Posted: May 9, 2012 in Java

NullPointerException:

Its is the child class of Run time Exception and it is unchecked exception.

if you are trying to apply any operation on null we will get NullPointerException

This is JVM Exception.

Example:

class Test{

public static void main(String… args)

{

String s = null;

System.out.println(s.length());

}

}

Output:

Exception in thread “main” java.lang.NullPointerException
at com.clarity.test1.main(test1.java:56)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s