Java examples for Reflection:Field Get
get Field By Field Name
//package com.java2s; import java.lang.reflect.Field; public class Main { public static Field getFieldByFieldName(Object obj, String fieldName) { for (Class<?> superClass = obj.getClass(); superClass != Object.class; superClass = superClass .getSuperclass()) {/*from w w w. j a v a 2 s. c o m*/ try { return superClass.getDeclaredField(fieldName); } catch (NoSuchFieldException e) { } } return null; } }