0
他の内部クラスで の継承を通じて内部クラスの保護されたフィールドにアクセスしようとしています。しかし、私は問題に遭遇しました:継承を介して内部クラスの保護されたフィールドにアクセス
package a;
class A{
public class Inner{
protected int i =5;
}
}
package b;
class B{
public class BInner extends A.Inner{
dsds
void test(){
System.out.println(i); // that's works fine, i
}
}
void print(){
System.out.println(new BInner().i) // but why i cant access this field from here? Compiler just says that there is protected access ...
}
}
このフィールドへのアクセス方法はありますか?
あなたの 'BInner'クラスは間違いなく動作しません。あなたの問題を表すコンパイル可能なコードを投稿してください。 –