Howdy ranchers,
James wrote:
I can still get to the value of x
Yes, but only from inside a Child object. You can't get the x from a Parent object outside its package.
And there is more: in the package other, you cannot access Child's x outside class Child.
If you try to compile this class:
So the protected fields in different packages are visible only through inheritance and only visible in classes (and subclasses of these) that inherit the class with the protected fields.
In the same package (other in the example) this fields are invisible in all classes that are no subclasses of the class (in the certif. package) with the protected fields (certification.Parents).
Complicated.
Yours,
Bu.