- class Fu
- {
- int num = 9;
- {
- System. out.println("Fu" );
- }
- Fu()
- {
- super();
- show();//这里省略了this.
- System.out.println("AAAA");
- }
-
- void show()
- {
- System. out.println("fu show " + num);//被覆盖,运行子类的
- }
- }
- class Zi extends Fu
- {
- int num = 8;
- {
- System. out.println("Zi" );
- }
- Zi()
- {
- super();
- show();
- }
- void show()
- {
- System. out.println("zi show " + num);
- }
- }
- public class ExtendsDemojava
- {
- public static void main(String[] args)
- {
- new Zi();
- }
- /*
- 在JDK1.6中输出结果为
- ————————————————————
- Fu
- zi show 0
- Zi
- zi show 8
- ————————————————————
- */
- }
复制代码 第二个为什么输出 zi show 0 ???
|