Possible Duplicate:
What is reflection, and why is it useful?
So I’ve been messing with the Reflection API lately, and it seems cool to screw around with here and there but what exactly is the use of it?
You see, it’s all fun to get field/method names and return types and set accessibility and whatnot, but how could this [reflection] possibly be of any use if you can read the java file/class with your own eyes?
Maybe I’m really ignorant or I don’t understand the full concept of this Reflection thingy, but could you explain to me in what ways this could be helpful?
There are times when you want to have a library which can handle any data types without having to read the class files.
e.g. Serialization, database connectivity frameworks, dependency injection frameworks, frameworks which use annotations.