Accessing a private method from outside of that class in JAVA
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Monday, December 16, 2002 12:43 AM

Is there any way i can access a private method or variable of a class from another class ?

Re: Accessing a private method from outside of that class in JAVA

Posted By:   Frank_Piet  
Posted On:   Friday, February 21, 2003 02:04 PM

You can create getter and setter methods on the class that contains the private methods (the methods of course must be public or friendly). These methods can in turn call or access the private members.

Hope this Helps

Re: Accessing a private method from outside of that class in JAVA

Posted By:   Simon_Ablett  
Posted On:   Monday, December 16, 2002 07:16 AM

No. That's whole purpose of private membership. If you want to access such a method or attribute then declare it as having either public or package (default) scope. Alternatively, make it protected if it is to be accessed by a child class.

Regards.
About | Sitemap | Contact