Java tutorial
//package com.java2s; import java.lang.reflect.Field; public class Main { private static Field scanField(Class<?> clazz, String... names) { for (String name : names) { try { final Field field = clazz.getDeclaredField(name); field.setAccessible(true); return field; } catch (NoSuchFieldException e) { } try { return clazz.getField(name); } catch (NoSuchFieldException e) { } } return null; } }