aspose file tools
The moose likes Beginning Java and the fly likes How could I do for acess a private method like that from another class? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "How could I do for acess a private method like that from another class?" Watch "How could I do for acess a private method like that from another class?" New topic
Author

How could I do for acess a private method like that from another class?

André Asantos
Ranch Hand

Joined: Nov 23, 2009
Posts: 234


How could I do for acess a private method like that from another class?


André AS
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
Using reflection. See http://tutorials.jenkov.com/java-reflection/private-fields-and-methods.html
André Asantos
Ranch Hand

Joined: Nov 23, 2009
Posts: 234
Thank you very much.
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3011
    
    9
Of course, private methods are designed not to be accessed from outside the class. If you find you need to do this, you may need to review your design.


Joanne
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35256
    
    7
Also, doing this may break the class if you're not careful (and may not be possible in the presence of a security manager, like if the code runs as part of a server).


Android appsImageJ pluginsJava web charts
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: How could I do for acess a private method like that from another class?
 
Similar Threads
Implementing compareTo
Comunication between classes
Set attribute value not serializable
Trouble creating a boolean method
HiLo game and NumberFormatException