同名訪問值我有abstract class和interface這樣在接口和抽象類的Java
abstract class ParentClass
{
int VALUE;
public abstract void display();
public void display2()
{
System.out.println("this is abstract class method");
}
}
interface parentInterface
{
int VALUE=88;
abstract void display();
void display2();
}
子類繼承和上述實現類似以下
class ChildClass extends ParentClass implements parentInterface
{
ChildClass()
{
super.VALUE=0;
//VALUE=0; //<=will give ambiguous property
}
@Override
public void display()
{
System.out.println("Current Class-"+this.getClass());
System.out.println("Integer value-"+super.VALUE);
}
public void display2()
{
//to call the method of abstract class
//call by using super.display2();
System.out.println("this is implemented method");
}
}
所以,我的問題是我如何訪問ChildClass中的接口VALUE
變量?
THIS.VALUE給出模棱兩可 –