aspose file tools*
The moose likes Beginning Java and the fly likes what is java reflection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "what is java reflection" Watch "what is java reflection" New topic
Author

what is java reflection

sudheer kiran
Ranch Hand

Joined: Jun 26, 2008
Posts: 237

what is java reflection and in which case it is useful..i am asking just for to know what is what.


Sudheer
SCWCD, SCJP 5
Ryan Clark
Greenhorn

Joined: Jun 23, 2008
Posts: 1
Hey Sudheer,

Java reflection is a technique your program can use to see and modify its own structure. If you don't know what kind of class you have or what its methods are, you can use reflection to find out, then instantiate and call methods on that object. And if I remember correctly, you can view method signatures through reflection, but you can't see the implementation.

As for practical application, I once had to write a web app that could test any kind of class (new classes could be added and we didn't want to change our app). To test them, I used reflection to instantiate the object and get a list of methods to show the user. Once they picked a method, I'd let them enter data, called the method, and returned the output to the user.

Hope this helps! (It's my first post!)
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36478
    
  16
I think it's helpful, Ryan, and welcome to JavaRanch

Sudheer K please check your private messages about an important administrative matter.
sudheer kiran
Ranch Hand

Joined: Jun 26, 2008
Posts: 237

hi thanks for the info
Siddharth Naik
Ranch Hand

Joined: Apr 09, 2006
Posts: 35
Here is a good article on reflection:
http://www.ibm.com/developerworks/library/j-dyn0603/


Thanks<br />Sid
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what is java reflection
 
Similar Threads
Java Reflection
skeletons -stubs
What is meant by .class ?
some java interview Questions
using java reflection