Can I access and get the value of object using java reflection
ther is method to get --getLong,getInt ,but I couldn't find getObject()
您只是在寻找Field.get(Object obj)
吗?
Class aClass = MyObject.class
Field field = aClass.getField("someField");
The example above will return the Field instance corresponding to the field someField
as declared in the MyObject below:
public class MyObject{
public String someField = null;
}
If no field exists with the name given as parameter to the getField() method, a
NoSuchFieldException is thrown.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.