【发布时间】:2013-10-18 15:05:43
【问题描述】:
在以下程序中:
public class PolyEx1 {
public static void main(String[] args) {
A refA = new A();
refA.method1(null);
}
}
class A {
public void method1(Object o) {
System.out.println("o");
}
public void method1(String str) {
System.out.println("str");
}
}
输出是“str”,有人能解释一下为什么打印str吗?我无法理解这一点。
【问题讨论】:
-
这不是多态性。超载了。
标签: java overloading