Forums Register Login

Finding Exposed Methods of a Class

+Pie Number of slices to send: Send
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!
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
"ESK"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the

JavaRanch Naming Policy.

You can change it

here.

Thanks! and welcome to the JavaRanch!

Mark
+Pie Number of slices to send: Send
Why does your bag say "bombs"? The reason I ask is that my bag says "tiny ads" and it has stuff like this:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 559 times.
Similar Threads
Coding Java Bean Using Constants Instead of Variables
Obtaining recNo from JTable - wrapping recNo in Room Object(UrlyBird)
Generics Confusion in Overriding a method
Methods not shown in VAJ EE 4.0.
I need design advice
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 00:59:16.