- class Fu
- {
- public String zifu="The parclass";
- public String getShow()
- {
- return zifu;
- }
- }
- class Zi extends Fu
- {
- public String zifu="The subclass";
- }
- class Test
- {
- public static void main(String[] args)
- {
- Fu fu=new Fu();
- System.out.println(fu.getShow());
- Zi zi=new Zi();
- System.out.println(zi.getShow());
- }
- }
复制代码 为什么运行的结果是
The parclass
The parclass
而不是
The parclass
The subclass呢?
|
|