Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
André Asantos
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


How could I do for acess a private method like that from another class?
 
Tom Reilly
Rancher
Posts: 618
 
André Asantos
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic