Can I 开发者_如何学JAVAaccess and get the value of object using java reflection
ther is method to get --getLong,getInt ,but I couldn't find getObject()
Are you looking for simply 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.
精彩评论