Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting Java class (public) fields and methods without API ?

 
justin smythhe
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to see the public methods and fields of a class without using API/docs ?
 
Greg Brannon
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The public fields of a class you've written? Of course. Most core Java or 3rd party API classes would not have public fields, so I'm not sure what you're asking. Can you give an example of a class you have in mind?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34178
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg: Technically, constants are public fields (and static/final) in a class you didn't write.

Justin: If you view the class in an IDE, you should be able to see this information. For example, in Eclipse, you do open type on that class and the outline view shows you all the fields and methods. Public and private for that matter.
 
Greg Brannon
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg: Technically, constants are public fields (and static/final) in a class you didn't write.

Absolutely. I didn't interpret the OP's question to be about constants, but you're absolutely right to include that in the answer space. Thanks for widening my thinking.
 
justin smythhe
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:Greg: Technically, constants are public fields (and static/final) in a class you didn't write.

Justin: If you view the class in an IDE, you should be able to see this information. For example, in Eclipse, you do open type on that class and the outline view shows you all the fields and methods. Public and private for that matter.


Thanks ! This is what it is like
How can I also see ALL the fields (including inherited) & methods of any Class used in my java code in eclipse ?
 
Campbell Ritchie
Sheriff
Posts: 48645
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean how to program something which shows all the fields in a class, or how to get an IDE like Eclipse to display them? For the former, you can try reflection. For an IDE, don’t you get views and perspectives which show all the class members. In Eclipse you get little icons of different colours: green for public, yellow for protected, blue for package private and red for private (I think). Doesn’t the help page you quoted tell you how to display them?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic