Java Q: I can’t access a public variable in my parent’s class’ inner class called foo. Why? setup is next(pseudo coded for brevity):
public class PageObject
{
public class Button
{
public String foo ="I want this string." //can't access....
}
....other stuff I can access here...
}
public class worker
{
public PageObject p = new PageObject();
}
public class workerchild extends worker
{
p.Buttons. <---don't have access to Buttons public variables, only .class, etc.
}
p.Buttonis a classname.Like any other classname, it can only be used to access static members.
You need to get an instance of the
Buttonclass. (eg,p.new Button().foo)