Java tutorial
//package com.java2s; //License from project: Apache License import java.lang.reflect.Field; import java.util.*; public class Main { public static Field findField(Object target, List<String> possible_names) { if (target == null) return null; for (Class<?> clazz = target.getClass(); clazz != null; clazz = clazz.getSuperclass()) { for (String name : possible_names) { try { return clazz.getDeclaredField(name); } catch (Exception e) { } } } return null; } }