如何使用子类中的父类变量

时间:2014-04-09 15:36:57

标签: java inheritance

class parent{
int a;
}

class child extends parent{
//how to get access to "a" here?
}

显然,声明同名int a的另一个变量将使用它,因为它来自类child

1 个答案:

答案 0 :(得分:0)

使用关键字supersuper.a应检索父变量,即使它已在子变量中再次定义。

相关问题