16. Dynamic Programming Through Reflection

Reflection is a mechanism for discovering data about a program at runtime. Reflection in Java enables you to discover information about fields, methods, and constructors of classes. You can also operate on the fields and methods that you discover. Reflection enables what is commonly referred to as dynamic programming in Java. Reflection in Java is accomplished using the Java Reflection API. This API consists of classes in the java.lang and the java.lang.reflect packages.

The things that you can do with the Java Reflection API include the following:

  • Determine the class of an object

  • Get information about a class’s modifiers, fields, methods, constructors, and superclasses

  • Find out what constants and method ...

Get Java™ Phrasebook 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.