File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to access private field and private method in Java

 
Ajit Aks Singh
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Saif Asif
Ranch Hand
Posts: 440
Eclipse IDE Hibernate Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greeting Ajit,

Why have you declare the getters as private ? The conventions say that you declare public getters/setters to access/change the values of the private members. Sy by convention you have to declare the getter methods of class MyTL as



Edit :
You can use reflection to access the private methods but that is not the recommended way to get the job done since by reflection , you do explicitly change the access modifier of the private method to public and then call it.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic