these days i read the java tutorials.And in the section "Controlling Access to Members of a Class" i have some trouble in the access level of modifier "protected".let me show the code:
package PackagesOne;
public class Alpha {
protected String name;
}
package PackagesTwo;
import PackagesOne.Alpha;
public class AlphaSub extends Alpha {
public static void main(String[] args){
Alpha alpha = new Alpha();
String name = alpha.name;
}
}
and in the PackagesOne i declare the String name of the modifier "protected",in the pacagesTwo the AlpaSub is subclass of the Alpha in the packagesOne.And my question is that in the java tutorial Controlling Access to Members of a Class,it say that the subclass in others packages can access the class members which are modified with protected.but i can not do it, when i javac the AlphaSub,it have error.