Q:

Java - Exceptio Handling(NullPointerException)

0

This Program is used to demonstrate Exception Handling NullPointerException concept.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

//NullPointerException 

class NullEx 
{ 
public static void main(String args[]) 
{ 
try 
{ 
String str=null; 
System.out.println(str.length()); 
} 
catch(NullPointerException e) 
{ 
System.out.println("\nNullPointerException : String is not declared"); 
} 
} 
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now