java
1package ex18; 2 3public class Parent { 4 int num = 10; 5 6}
java
1package other; 2 3import ex18.Parent; 4 5public class Child extends Parent { 6 7 public static void main(String[] args) { 8 System.out.println(num); 9 } 10 11}
コンパイルで、Childクラスに対してnumは不可視であるという旨のコンパイルエラーが出ますが、これは問題的にどうなのでしょうか。仮にprotectedに変更しても、stasticから非staticは参照できないと思います。
回答1件
あなたの回答
tips
プレビュー