Modifying Data Members and Calling Methods

The three examples so far have shown interrogating classes and interfaces from their class definitions. The methods used so far, such as getFields(), provide static information about what a class looks like. This is useful if you want to get information about what a class or interface contains. If you want to find out about an object and then use it, or find out what fields and methods a class contains so that you can make an instance of that class and modify its values or call its methods, you can use the methods provided by the Reflection APIs. First, you can create an object using a constructor, and then you can set or get attribute values or call methods. You can create an object in Java by calling ...

Get PURE Java™ 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.