get Field Value as Object - Android java.lang.reflect

Android examples for java.lang.reflect:Field Value

Description

get Field Value as Object

Demo Code


//package com.java2s;
import java.lang.reflect.Field;

public class Main {
    public static Object getFieldValueObject(Object obj, Field field) {

        try {//  w ww.  j  av  a 2 s .  c o m
            return field.get(obj);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }

        return null;
    }
}

Related Tutorials