import java.lang.reflect.Field;
public class Main {
public static void main(String[] argv) throws Exception {
Class cls = java.awt.Point.class;
Field field = cls.getField("x");
// Get value
// field.getInt(object);
// Set value
// field.setInt(object, 123);
// Get value of a static field
field.getInt(null);
// Set value of a static field
field.setInt(null, 123);
}
}
|