Java Reflection Field Value Set setFieldValue(Field field, Object obj, Object value)

Here you can find the source of setFieldValue(Field field, Object obj, Object value)

Description

set Field Value

License

Apache License

Declaration

static private void setFieldValue(Field field, Object obj, Object value) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.lang.reflect.Field;

public class Main {
    static private void setFieldValue(Field field, Object obj, Object value) {
        if (field != null) {
            try {
                field.set(obj, value);/*  w ww.  ja v  a  2s  .c  o m*/
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            }
        }
    }
}

Related

  1. setFieldValue(Class clazz, String fieldName, Object value)
  2. setFieldValue(Class clazz, String fieldName, Object value)
  3. setFieldValue(Class expectedType, Object target, String fieldName, T value)
  4. setFieldValue(Field f, Object target, Object value)
  5. setFieldValue(Field field, Object instance, T value)
  6. setFieldValue(Field field, Object object, Object value)
  7. setFieldValue(Field field, Object object, Object value)
  8. setFieldValue(Field field, Object target, Object value)
  9. setFieldValue(Field field, Object value, Object instance)