Azrael Noor wrote:In Reflection i am able to get few details of private variable, could we also get data of it ?
Like Henry said, it is possible to get the value from a private variable in a different class using reflection, but the Security Manager has to allow it - so you can't be sure it will always work unless you can also control the security manager the application runs in.
Joined: Oct 13, 2005
When I, earlier wrote: . . . ordinary programming.
… I meant not using reflection. You can cause no end of trouble by using reflection to circumvent somebody else’s programming style.
as Vishal said, inner classes have direct access to private members of the outer class. another option is, if both classes are in the same package, make the member variable package access(no modifier) and give the "want's access class" a constructor that takes the "wanted class as a parameter.