List methods of a class using Reflection

In this example we use the Reflection api to obtain the methods of a particular class called Person, which is an inner class.
First we need to get the Class object and we do so by calling ‘Person.class’. Once we have the Class object we can use it to call the getDeclaredMethods() method which will return an array of type Method.
To find out the names of the methods that the Person class contains we simply loop through the array and call getName() for each Method object.

If you run the example code above the output will be:

Search for more Java info on this site here:
Custom Search

Please type any questions here.