Java tutorial
//package com.java2s; //License from project: Apache License import java.lang.reflect.Field; public class Main { public static Object getField(Class<?> clazz, String fieldName, Object object) throws NoSuchFieldException, IllegalAccessException { Field field = clazz.getDeclaredField(fieldName); field.setAccessible(true); return field.get(object); } }