Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Reflection API : A Brief Introduction 
 

Reflection API is a powerful technique (that provides the facility) to find-out its environment as well as to inspect the class itself. Reflection API was included in Java 1.1.

 

Reflection API : A Brief Introduction

                         

In this section you will learn about the Reflection API.

Reflection API is a powerful technique (that provides the facility) to find-out its environment as well as to inspect the class itself. Reflection API was included in Java 1.1. The classes of Reflection API are the part of the package java.lang.reflect and the methods of Reflection API are the parts of the package java.lang.class. It allows the user to get the complete information about interfaces, classes, constructors, fields and  various methods being used. It also provides an easy way to create a Java Application that was not possible before Java 1.1. You can create methods like event handlers, hash code etc and also find-out the objects and classes.

With the help of Reflection API you can get the information about any class of the java.lang package. There are some useful methods like getName() and getInterfaces(), which allows us to retrieve the name of the class and the interfaces of the package respectively.

Avoid using Reflection API in those applications wherever it affects the application's performance, security related code of the application such as in Applet programming. Reflection API also affects the application if the private fields and methods are there.

Here we are providing few of the examples to give a better overview of the Reflection API :

1.    Getting the implemented Interfaces
In this section you will learn how to retrieve an Interface (that included in the program) by using the getInterfaces() method. Here is an example that provides the usage of the getInterfaces() method in more detail.

2.    Retrieving the class name through Reflection API
A more generic way, how to retrieve the name of the class (that is used in the program) that reflects the package name by using the getName() method. Here is an example that provides the proper way to use the getName() method.

3.    Finding out the superclass name of the Class
Here we show you the way to find out the Superclass name by using the getSuperclass() method. The given example demonstrates the use of getSuperclass() method in more detail.

4.    Getting the method name used in the Application
In this section we describe how to retrieve method name by using the getMethods() method. Here is an example that demonstrates the use of the getMethods() method in more detail.

5.    Finding out the object of the Class
This section illustrates how to retrieve an object name that reflects the package name by using the object.getClass() method. Here is an example that provides the proper usage of the object.getClass() method in more detail.

6.    Finding out the class fields
This section explores you, how to retrieve the fields of the class by using the getFields() method. For this we are taking an example that provides the use of the getFields() method in detailed way.

7.    Getting information about Constructor
In this section you will learn, how to retrieve the information about the constructor by using the getConstructors() method. Here is an example that provides the usage of the getConstructors() method.

                         

» View all related tutorials
Related Tags: java c ide class reference object io integer method get vi field using fields int this id ai create for

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.