Java tutorial
//package com.java2s; import java.lang.reflect.Field; public class Main { public static Object set(Field f, Object obj, Object value) throws IllegalArgumentException, IllegalAccessException { f.setAccessible(true); f.set(obj, value); return f.get(obj); } public static Object get(Field f, Object obj) throws IllegalArgumentException, IllegalAccessException { f.setAccessible(true); return f.get(obj); } }