According to the second table of documentation (http://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html) a member with no identifier is not visible to a subclass.
But, when I run the following sample code, "1" (content of b) is printed!
class Class1{
private int a=0;
int b=1;
protected int c=2;
public int d=3;
}
class Class2 extends Class1{ }
public class HelloWorld{
public static void main(String []args){
Class2 klass=new Class2();
System.out.println(klass.b);
}
}
If a member, with no access modifier, is not accessible from a subclass why is it printed in this example?
It should throw an error, like in private access modifier, shouldn't it?