> My question involves child class access to protected member of parent
> class.
> Why do we neet a public method to access protected class member
> Ex6BaseInner of parent Ex6Base? Don't subclasses have access to
> protected member of parent class?
The line "return new Ex6BaseInner();" relies on an accessible
constructor, but there are none because the default constructor of
Ex6BaseInner is protected due to Ex6BaseInner being a protected class.
See section 8.8.9 in the JLS [1] for details.
You example will work if you just add a public constructor to Ex6BaseInner.
[1]
http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.8.9
Regards,

Signature
Filip Larsen
Piotr Kobzda - 13 Apr 2007 08:13 GMT
>> My question involves child class access to protected member of parent
>> class.
[quoted text clipped - 9 lines]
>
> You example will work if you just add a public constructor to Ex6BaseInner.
Another solution, not requiring publicly accessible constructor in
Ex6BaseInner, might be introducing another inner class in the Ex6 which
extends inherited Ex6BaseInner class. In particular, that inner class
may be anonymous, so the following should work as well:
return this.new Ex6BaseInner() { };
piotr