- <p>class A
- {
- public void show()
- {
- show2();
- }
-
- public void show2()
- {
- System.out.println("我");
- }
- }</p><p>class B extends A
- {
- public void show2()
- {
- System.out.println("爱");
- }
- }
- class C extends B
- {
- public void show()
- {
- super.show();
- }
-
- public void show2()
- {
- System.out.println("你");
- }
- }
- public class Test
- {
- public static void main(String[] args)
- {
- A a = new B();
- a.show();
- B b = new C();
- b.show();
- }
- }
- </p>
复制代码
大家一块看看,分析一下下,很有意思的
|
|