Java Reflection Field Find findField(Class clazz, String fieldName)

Here you can find the source of findField(Class clazz, String fieldName)

Description

find Field

License

Open Source License

Declaration

public static Field findField(Class<?> clazz, String fieldName) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.lang.reflect.Field;

public class Main {
    public static Field findField(Class<?> clazz, String fieldName) {
        for (Field field : clazz.getDeclaredFields()) {
            if (field.getName().equals(fieldName))
                return field;
        }/*w w  w. j a v a  2 s. c  o  m*/
        return null;
    }
}

Related

  1. findField(Class claz, String... names)
  2. findField(Class clazz, final String field)
  3. findField(Class clazz, String field)
  4. findField(Class clazz, String field, Class type, int index)
  5. findField(Class clazz, String fieldName)
  6. findField(Class clazz, String fieldName)
  7. findField(Class clazz, String fieldName)
  8. findField(Class clazz, String fieldName)
  9. findField(Class clazz, String fname, boolean isSearchSuperclass)