
public class Parent {
public void method() {
}
}
public class Child extends Parent {
private void method() {//编译就会出错
}
}
public class Test{
public void otherMethod() {
Parent p1 = new Parent();
Parent p2 = new Child();
p1.method();
p2.method();
}
}//源代码片段来自云代码http://yuncode.net



