O'Reilly logo

PURE Java™ 2 by Kenneth Litwak

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting Constructor and Method Information with Reflection

Just as you can get information on class attributes and data members, you can use the Reflection APIs to get information on the methods of a class. The getConstructors() method returns a group of Constructor objects for each constructor in the class. The getMethods() method returns an array of Method objects, one for each method in the class.

Reflection of Constructor and Method Information: Code Example

Listing 13.2 shows how to get the methods and constructors for a class. As with fields, you can obtain the modifiers for a constructor or method, and the parameters as well. You could then use this information to create an instance of the class or call a method on an instance of the class. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required