Java tutorial
//package com.java2s; import java.lang.reflect.Field; public class Main { private static Field getFieldByNameFromAnywhere(Class<?> aClass, String fieldName) { Field result = null; try { result = aClass.getDeclaredField(fieldName); } catch (Exception e) { result = getFieldByNameFromAnywhere(aClass.getSuperclass(), fieldName); } return result; } }