- 继承时
this.成员变量
– this所在类
的成员变量this.成员函数
– 当前new对象所在类
的成员函数
class Fu{
int num = 3;
public void show(){
System.out.println("Fu show");
}
public void getNum(){
System.out.println("getNum() = " + this.num);
this.show();
}
}
class Zi extends Fu{
int num = 1;
public void show(){
System.out.println("Zi show");
}
}
class Demo{
public static void main(String[] args){
Fu f = new Zi();
System.out.println("f.num = " + f.num);
f.getNum();
}
}
注意
:
- 如您发现本文档中有错误的地方,
- 或者您发现本文档中引用了他人的资料而未进行说明时,请联系我进行更正。
- 转载或使用本文档时,请作说明。
- 非常感谢
:)