Get specific property of object using java Reflection?

You can use Apache Common's ReflectionUtils and BeanUtils class to help you out. ReflectionUtils has several helper methods that can help in discovering properties you are interested in and BeanUtils has helper methods to populate the values of properties/fields.

1 He needed a solution using Reflection. – Faisal Feroz Oct 10 '10 at 8:12.

Unless there is a specific reason to use reflection, it is better not to use it. If you are looking for using reflection because it will be convinient or it will take fewer lines of code/make code readable, then note that this is not true. Generally reflection code is less readable, and you are almost always better off using the normal way of invoking methods.

Reflection is suitable when, say, your method names are known only at runtime (via a properties file or something) If for any reason, you need reflection, see this.

If I understood task in correct way, you can do it without reflection. Abstract class Embedded { private static final Set obj = ...; { //init obj } protected Embedded(int id){ set. Add(id); } public static Set getAllIDs(){ return obj; //return copy or immutable collection } }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions