Object anObject = ....;
Field[] fields = anObject.getClass().getDeclaredFields();
//to obtain the value of the field for anObject
Field field = fields[0];
field.setAccessible( true );//since declared fields also returns private fields
Object fieldValue = field.get( anObject );
# 1 楼答案
有关反射的更多信息,请参阅Java reflection tutorial
我不知道你所说的“获取向量的值”是什么意思,但检索对象的场相当简单。比如