多个重载方法:null 是否等于 NullPointerException?
2022-09-01 18:39:19
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 方法调用