aspose file tools*
The moose likes Java in General and the fly likes Regarding Reflection... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Regarding Reflection..." Watch "Regarding Reflection..." New topic
Author

Regarding Reflection...

Sriram Sharma
Ranch Hand

Joined: Apr 12, 2006
Posts: 92
Hi All,

Can somebody gimme some info about what is Reflection and how is it used with some good examples?

Regards,
Sriram.
Eitan Levi
Greenhorn

Joined: Jun 14, 2006
Posts: 14
Reflection (see Wikipedia entry) is all about interacting with the runtime environment as it's running. Languages that support reflection give you different means of getting information from runtime objects (like classes) and some even go as far as letting you dynamically create new classes and methods at runtime.

In Java, Reflection can be used to get information about in-memory objects, the classes that they are instances of, the methods in those classes, what kind of parameters they take, what kind of fields are defined in the class, are they public/private/protected, etc. etc. etc.

Here is a crude example: this program reads a method name from the command line, finds it in the class and tries to invoke it on the object.





There's a good tutorial on the Reflection API from java.sun.com that you can follow to get a nice introduction to it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding Reflection...
 
Similar Threads
EL Mystery
How to get an specific object instance!
print a parameter name and value (with a function)
Java Reflection
Do IDEs use Reflection API