Java Reflection Field Value Set setFieldValue(Object object, String fieldName, Object fieldValue)

Here you can find the source of setFieldValue(Object object, String fieldName, Object fieldValue)

Description

set Field Value

License

Apache License

Declaration

public static void setFieldValue(Object object, String fieldName, Object fieldValue) throws Exception 

Method Source Code


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

import java.lang.reflect.Field;

public class Main {
    public static void setFieldValue(Object object, String fieldName, Object fieldValue) throws Exception {
        Field field = object.getClass().getDeclaredField(fieldName);
        field.setAccessible(true);/*from   w w w .j  av  a 2s. c o  m*/
        field.set(object, fieldValue);
    }
}

Related

  1. setFieldValue(Object obj, String fieldName, Object value)
  2. setFieldValue(Object obj, String fieldName, String fieldValue)
  3. setFieldValue(Object obj, String name, Object value)
  4. setFieldValue(Object object, Field field, Object value)
  5. setFieldValue(Object object, String fieldName, Object fieldValue)
  6. setFieldValue(Object object, String fieldName, Object fieldValue)
  7. setFieldValue(Object object, String fieldName, Object value)
  8. setFieldValue(Object object, String fieldName, Object value)
  9. setFieldValue(Object object, String fieldName, Object value)