Software development tools, such as GUI builders and debuggers, need to manipulate objects at run time. For example, a GUI builder may allow the end-user to select aButton
from a menu of components, create theButton
object, and then click theButton
while running the application within the GUI builder. If you're in the business of creating software development tools, you'll want to take advantage of the reflection API features described in this lesson.Creating Objects
How can you create an object if you don't know its class name until run time? You'll find the answer in this section.Getting Field Values
In this section you'll learn how to get the values of an object's fields, even if you don't know the name of the object, or even its class, until run time.Setting Field Values
Not only can you get field values at run time, you can also set them. This section shows you how.Invoking Methods
This section shows you how to dynamically invoke methods. Given an object, you can find out what methods its class defines, and then invoke the methods.
Wednesday, 22 September 2010
Manipulating Objects
Labels:
java,
Reflection
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment