Java by API/java.lang/NullPointerException

Материал из Java эксперт
Перейти к: навигация, поиск

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);
    }
  }
}