Java tutorial
//package com.java2s; import java.lang.reflect.Field; public class Main { public static Object getProperty(Object o, String field) { try { Field f = o.getClass().getDeclaredField(field); return f.get(o); } catch (Exception e) { e.printStackTrace(); } return null; } }