This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
here's a full list of what you can do with reflection from the reflection trail in the java tutorial: 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 interface. -Create an instance of a class whose name is not known until runtime. -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 type are not known until runtime, and then modify the array's components.
Cheers, Su Yeu [ January 18, 2006: Message edited by: Su Yeu ]
A Moment's insight is sometimes worth a Life's experience.
Tauri Valor
Ranch Hand
Joined: Aug 03, 2005
Posts: 166
posted
0
Well I request the Bartenders, and Sheriffs to continue "Technical Interview Questions" as long as it goes. Why dont we start a seperate section for this?
Originally posted by Su Yeu: Well I request the Bartenders, and Sheriffs to continue "Technical Interview Questions" as long as it goes. Why dont we start a seperate section for this?
Actually, I am sorely tempted to close this thread every time someone posts to it and it rises back to the top. The whole notion of a list of "interview questions" is absolutely counter to what we want to do here at the Ranch. JavaRanch wants you to learn Java -- not memorize answers to interview questions so you can get a job you're not qualified for. You should get a job because you really know the material based on experience -- not because you crammed for an interview.
Originally posted by John Ipe: Reflection is used mostly in tool development, such as class browsers, debuggers etc. when you want to retrieve information about classes and objects at runtime.
It's much more widely used than that. Think frameworks and "services" like Hibernate, for example. Hibernate reads config files with lines like
<property name="name" column="USERNAME"/>
And either generates calls to getName/getName or direct access to the field name.