new NullPointerException(String name)
/*
* Output:
*
* recaught: java.lang.NullPointerException: demo
*
*/
public class MainClass {
public static void main(String args[]) {
try {
throw new NullPointerException("demo");
} catch (NullPointerException e) {
System.out.println("recaught: " + e);
}
}
}
Related examples in the same category