开发者

Doubts Over Base Class Access

开发者 https://www.devze.com 2023-01-18 13:57 出处:网络
I have 2 classses - PageScreen - Which is a base class that contains a labelfield, with some text in it开发者_StackOverflow中文版.

I have 2 classses -

PageScreen - Which is a base class that contains a labelfield, with some text in it开发者_StackOverflow中文版.

TestScreen - This class extends PageScreen. Based on the focus of the elements in this screen, I need to change the value of a label in PageScreen.

How do I access the labelField variable in PageScreen from TestScreen?


If I have understood your question correctly - you could have this setup

class PageScreen{
    String labelField;

    public void setLabelField(String labelField){
        this.labelField = labelField;
    }

    public String getLabelField(){
        return labelField;
    }
}

class TestScreen extends PageScreen{
    public String getLabelField(){
        return super.getLabelField();
    }
}

This should work.

0

精彩评论

暂无评论...
验证码 换一张
取 消