以下のコード例では、親クラスの列挙型の値をテストしようとしています。私が得るエラーは「p.theEnumを解決できないか、フィールドではありません。」ですが、値をテストするために親クラスで使用するコードとまったく同じです(明らかにp.なし)。
どこが間違っていますか?:)
public class theParent {
protected static enum theEnum { VAL1, VAL2, VAL3 };
private theEnum enumValue = theEnum.VAL1;
theParent() { this.theChild = new theChild(this); this.theChild.start(); }
class theChild {
private parentReference p;
public theChild (theParent parent) { this.p = parent; }
public void run() {
// How do I access theEnum here?
if (p.enumValue == p.theEnum.VAL1) { }
}
}
}