Easy to Learn Java: Programming Articles, Examples and Tips

Start with Java in a few days with Java Lessons or Lectures


Code Examples

Java Tools

More Java Tools!

Java Forum

All Java Tips


Submit News
Search the site here...
Search the JavaFAQ.nu
1000 Java Tips ebook

1000 Java Tips - Click here for the high resolution copy!1000 Java Tips - Click here for the high resolution copy!

Java Screensaver, take it here

Free "1000 Java Tips" eBook is here! It is huge collection of big and small Java programming articles and tips. Please take your copy here.

Take your copy of free "Java Technology Screensaver"!.

When do I need to use reflection?

JavaFAQ Home » General Java Go to all tips in General Java

Bookmark and Share

Question: When do I need to use reflection?

Answer: Reflection is a feature in the Java programming language.
It allows an executing Java program to examine or "introspect" upon itself, and manipulate internal properties of the program. For example, it's possible for a Java class to obtain the names of all its members and display them.
The ability to examine and manipulate a Java class from within
itself may not sound like very much, but in other programming
languages this feature simply doesn't exist. For example, there
is no way in a Pascal, C, or C++ program to obtain information
about the functions defined within that program.

The reflection API represents, or reflects, the classes,
interfaces, and objects in the current Java Virtual Machine.
You'll want to use the reflection API if you are writing
development tools such as debuggers, class browsers, and GUI
builders. With the reflection API you can:
Determine the class of an object.
Get information about a class's modifiers, fields, methods,
constructors, and superclasses.
Find out what constants and method declarations belong to an
Create an instance of a class whose name is not known until
Get and set the value of an object's field, even if the field
name is unknown to your program until runtime.
Invoke a method on an object, even if the method is not known
until runtime.
Create a new array, whose size and component types is not known
until runtime, and then modify the array's components.

Read more about reflection here:

 Printer Friendly Page  Printer Friendly Page
 Send to a Friend  Send to a Friend

.. Bookmark and Share

Search here again if you need more info!
Custom Search

Home Code Examples Java Forum All Java Tips Books Submit News, Code... Search... Offshore Software Tech Doodling

RSS feed Java FAQ RSS feed Java FAQ News     

    RSS feed Java Forums RSS feed Java Forums

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest 1999-2006 by Java FAQs Daily Tips.

Interactive software released under GNU GPL, Code Credits, Privacy Policy