Java tutorial
//package com.java2s; import java.lang.reflect.Field; public class Main { private static Field findField(String attrName, Field[] fields) { if (attrName == null || "".equals(attrName.trim()) || fields == null || fields.length == 0) return null; for (Field f : fields) { String fName = f.getName(); if (attrName.equals(fName)) return f; } return null; } }