Java Exception throws null pointer exception
public class Main { public static void main(String[] args) { try {/*www . jav a 2 s. co m*/ test(null); } catch (NullPointerException e) { System.out.println("There was an null parameter!"); } } private static void test(Object o) { if (o == null) throw new NullPointerException("The object is null"); } }