Java Reflection Field Value Set SetFieldValue(Object o, String field, Object object)

Here you can find the source of SetFieldValue(Object o, String field, Object object)

Description

Set Field Value

License

Apache License

Declaration

public static void SetFieldValue(Object o, String field, Object object)
        throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException 

Method Source Code


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

import java.lang.reflect.Field;

public class Main {

    public static void SetFieldValue(Object o, String field, Object object)
            throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
        Field _field = o.getClass().getDeclaredField(field);
        _field.setAccessible(true);//  w w  w. ja  v  a2s  . com
        _field.set(o, object);
    }
}

Related

  1. setFieldValue(Object host, Field f, Object value)
  2. setFieldValue(Object input, Object value, String fieldName)
  3. setFieldValue(Object instance, Field field, Object value)
  4. setFieldValue(Object instanceContainingField, String fieldName, Object fieldValue)
  5. setFieldValue(Object o, Class baseClass, Class fieldType, T value)
  6. setFieldValue(Object obj, Field f, Object value)
  7. setFieldValue(Object obj, Field field, Object value)
  8. setFieldValue(Object obj, Field field, Object value)
  9. setFieldValue(Object obj, String field, Object value)