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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
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: 3170
    
  10
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: 39578
    
  27
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).


Ping & DNS - updated with new look and Ping home screen widget
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How could I do for acess a private method like that from another class?
 
Similar Threads
Comunication between classes
Implementing compareTo
HiLo game and NumberFormatException
Set attribute value not serializable
Trouble creating a boolean method