Tag: overloading

多个重载方法:null是否等于NullPointerException?

public class TestMain { public static void methodTest(Exception e) { System.out.println(“Exception method called”); } public static void methodTest(Object e) { System.out.println(“Object method called”); } public static void methodTest(NullPointerException e) { System.out.println(“NullPointerException method called”); } public static void main(String args[]) { methodTest(null); } } 输出:调用NullPointerException方法