Java tutorial
//package com.java2s; public class Main { /** * @param clz class name * @param fieldName field name * @return true if the field is in the class, else false */ public static boolean existsField(Class clz, String fieldName) { if (null != clz) { try { return clz.getDeclaredField(fieldName) != null; } catch (Exception e) { } if (clz != Object.class) { return existsField(clz.getSuperclass(), fieldName); } } return false; } }