both files are in c:\java. Package directory? they have to be in seperate folders from the same directory c:\java\certification and c:\java\other Ill try that
okay that did not work, I can also take your response as leave Child.java and Parent.java in c:\java and just create a certification folder as well as a other folder but that does not seem like it would work that way either. [ August 03, 2007: Message edited by: James Hambrick ]
after some fooling around I found that you have to have in this example a Other folder with the Child.java file and a certification folder inside the other folder. Inside the certification folder you need the Parent.java file.
okay now that it works and I see that I cannot do this
because x is protected and I get a compile error as the book stated. It got me thinking. declaring a object of Parent inside the child class is composition(I think that's what it was called). But since its inherited you can declare an object of Child and it work fine. what would be the actual difference? 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).
all events occur in real time
So I left, I came home, and I ate some pie. And then I read this tiny ad: