Java tutorial
import java.awt.Rectangle; import java.lang.reflect.Field; public class Main { public static void main(String[] args) { Rectangle r = new Rectangle(100, 325); Class c = r.getClass(); try { Field heightField = c.getField("height"); heightField.setInt(r, 1000); Integer heightValue = (Integer) heightField.get(r); System.out.println("Height: " + heightValue.toString()); } catch (Exception e) { System.out.println(e); } } }