Is there a utility to get a property which isnt prefixed by get from an object using reflection similar to BeanUtils? e.g. if I specify "hashCode" and I want to get the object.hashCode() value.
Thanks.
You can call hashCode() on every Object. You don't need reflection for this.
Otherwise, you can use the standard reflection classes - java.lang.Class and its method getMethod(..) which returns java.lang.reflect.Method.
The java reflection API allows you to access any property on a given instance of a class, including private variables.
Reflection is a powerful tool that allows you to do many things, including instantiating objects with private constructors.
Here is a decent tutorial for reflection that a quick google search turned up.
http://tutorials.jenkov.com/java-reflection/index.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With