アクセス就職子protectedについて理解が足りないので教えてください。 protectedつけることで、 『自分のクラス内のメソッド 又は 継承されたサブクラス内のメソッドからしかアクセスできない』 そのように直感的に感じたのですが、 間違っているようで。 public class Purotekuto { public static void main(String[] args) { Test21 hogehoge = new Test21(); System.out.println( "値を出力:" + hogehoge.protectedInteger ); }} public class Test21 { protected int protectedInteger; Test21() { this.protectedInteger = 0; } public void setValue( int value ) { this.protectedInteger = value; } public int getValue( int value ) { return this.protectedInteger; }} このコードでは、main()から、クラスTest21のメンバ、protectedIntegerにアクセスできずに、 エラーか何かになると思ったのですが、普通に動きました。 自分の考えの何がまずいのでしょうか。。。