Java tutorial
//package com.java2s; import java.lang.reflect.Field; public class Main { public static Object getField(String fieldName, Class clazz, Object object) { try { Field f = clazz.getDeclaredField(fieldName); f.setAccessible(true); return f.get(object); } catch (Exception e) { return null; } } }