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

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

Description

Sets a field value via reflection.

License

Open Source License

Declaration

static void setFieldValue(Object instance, Field field, Object value) 

Method Source Code

//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

import java.lang.reflect.Field;

public class Main {
    /** Sets a field value via reflection. */
    static void setFieldValue(Object instance, Field field, Object value) {
        try {/*from ww w .j  a v a  2 s  .  c  o  m*/
            field.set(instance, value);
        } catch (IllegalAccessException e) {
            throw new IllegalStateException(e);
        }
    }
}

Related

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