【发布时间】:2015-03-11 21:26:56
【问题描述】:
我在搞乱方法并正在寻找,如果我创建两个名为“hello”的方法,使用不同的对象并将“null”传递给方法,将执行哪个方法:
public static void main(String... args) {
hello(null);
}
public static void hello(Window w) {
System.out.println("Hello");
}
public static void hello(Frame f) {
System.out.println("Bye");
}
每次输出都是“Bye”,但我还是不明白这背后的逻辑。 在谷歌进行了简短的研究后,没有任何解释,我决定在这里问这个问题。
希望有人能解释一下选择算法或者给我一个解释的链接。
【问题讨论】:
标签: java methods compiler-construction