Why is a field with no modifier visible in a subclass?
My super class:
public class SuperClass {
String s = "superString";
public void method(){
System.out.println("Super");
}
}
My sub class:
public class Test extends SuperClass{
public static void main(String args[]){
Test t = new Test();
System.out.println(t.s);
}
}
I get no error message from eclipse, the program prints out: superString...
But it shouldn't as no modifier fields are only visible in the class and the package but not in sub classes, or what have I misunderstood? Thanks