- package packb;
- public class DemoB
- {
- protected void method(){
- System.out.println("DemoB method run");
-
- }
- }
- package packa;
- public class DemoA extends packb.DemoB
- {
- public void show(){
- System.out.println("DemoA show run");
-
- }
- }
- package pack;
- class PackageDemo
- {
- public static void main(String[] args)
- {
- packa.DemoA d = new packa.DemoA();
- d.show();
- d.method();
- }
- }
复制代码 为什么对象d不能访问method方法呢?
|
|