Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Beginning Java and the fly likes Finding Exposed Methods of a Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Finding Exposed Methods of a Class" Watch "Finding Exposed Methods of a Class" New topic

Finding Exposed Methods of a Class

K Sujit
Ranch Hand

Joined: Mar 23, 2005
Posts: 33
Hi All,

I have many classes with only set and get methods. The number of set and get methods differ from class to class. Obviously it depends upon the number of instance variables that particular class has.

Now suppose I got a class C, I want to find what all methods it is exposing. How can I do that.

Thanks in advance!

I wish java run in my veins.
Steve Morrow
Ranch Hand

Joined: May 22, 2003
Posts: 657

Options include (in roughly preferential order, and not limited to) reading the API docs for the class, relying on an IDE, looking at the source, or using reflection.

Hope this helps.
Rick Stabile

Joined: Sep 22, 2005
Posts: 6
I did something similar recently. Only I exposed a class's fields rather than its methods using the Class.getFields() method. I talk about it here: Reflection made my life easier today..

Rather than use the getFields() method, you would probably want to use the getMethods() method. Look at the javadoc for the Class class - Javadoc for Class. There's a lot of interesting stuff there.

- Rick S.
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Welcome to the JavaRanch! Please adjust your displayed name to meet the

JavaRanch Naming Policy.

You can change it


Thanks! and welcome to the JavaRanch!


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
K Sujit
Ranch Hand

Joined: Mar 23, 2005
Posts: 33
Thanks all!

I found what I wanted at

I agree. Here's the link:
subject: Finding Exposed Methods of a Class
It's not a secret anymore!