Can I invoke methods dynamically, from names (String instances) that are determined at run time?
Ans : Yes; the reflection API in the JDK 1.1 lets you invoke methods by means of run-time strings representing method names, but use of this facility is not recommended as a general design strategy. Starting in the JDK 1.1, the Class class and the new java.lang.reflect package expand your ability to inspect and manipulate classes and methods at run time. The reflection API also lets you pull out individual elements from a class or class instance and act on them. You can: • invoke a method by means of a Method instance fetched at run time (using Method’s invoke method) • change the value of a field by means of a Field instance fetched at run time (using one of Field’s set… methods) • create a new class instance by means of a Constructor object fetched at run time (using Constructor’s newInstance method) These capabilities are essential for component integration frameworks, such as JavaBeans, and for application builder tools. Let’s focus now on methods. Invoking a method dynamically r