[hotjoe.com] HotJoe Java Help Forums
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Visit java.com
Missing post? - see this post about spam for more information.
is it possible  XML
Forum Index » Java Programming
Author Message
santo

Newbie

Joined: 10/03/2005 02:39:53
Messages: 4
Offline

i am trying to access the private member of a class
from outside is it possible.
my friend told to me it's possible.
stdunbar

Newbie
[Avatar]

Joined: 06/22/2005 14:51:37
Messages: 884
Location: Superior, CO, USA
Offline

It is diificult but possible. Basically you will need to use reflection and force the field to be visible. The code looks something like:



Now theField, a member of theClass is, in effect, public.

Thanks for using the forums at hotjoe.com
[WWW] [Yahoo!] [ICQ]
yawmark

Newbie

Joined: 06/24/2005 10:10:08
Messages: 13
Location: WDSM, IA
Offline

I'd also add that in almost all circumstances, it's also a bad idea. Reflection can be abused to break encapsulation, which is one of the fundamental principles of good OOP and design.
[MSN]
 
Forum Index » Java Programming
Go to:   
Powered by JForum 2.1.9 © JForum Team
This site run by Scott Dunbar of Xigole Systems. © 2005-2012 - Scott Dunbar
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners
hotjoe.com, xigole.com, and Scott Dunbar have no affiliation with Oracle