Rob Prime wrote:Only through reflection, and only if the security manager allows it. In general, it's a case of bad design - either by the person that created the class for not providing getters / setters or by you for trying to access something you really shouldn't. (Usually it's the former.)
If a data member is private, then following won't work:
object.privateMember; //error, privateMember is private
Like Rob said above, if you are supposed to have access to this data then there will be a getter method, and it will probably look something like this:
object.getPrivateMember();
If you can't find a method like the one above, then someone needs to consider redesigning something.