Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Access to a non-accessible member of an enclosing type?

843785Nov 6 2008 — edited Nov 7 2008
This as a meta-compiler error you can check for in Eclipse,

"Access to a non-accessible member of an enclosing type"

You get this error when an inner class accesses a private member of the outer class.

Isn't this perfectly valid according to Java? To access an outer private member from an inner class?

Still, it seems Eclipse considers this ineffective and suggests you should change the private member from private to non-private.

I don't quite get this. Should one give up encapsulation to overcome some Java implementation inefficiency?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 5 2008
Added on Nov 6 2008
33 comments
408 views