Java Reflection Field Set setField(String field, Object object, Object value)

Here you can find the source of setField(String field, Object object, Object value)

Description

set Field

License

Open Source License

Declaration

public static void setField(String field, Object object, Object value) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.lang.reflect.Field;

public class Main {
    public static void setField(String field, Object object, Object value) {
        try {//  www. j  a va2  s  . c  o  m
            Field entryField = object.getClass().getDeclaredField(field);
            entryField.setAccessible(true);
            entryField.set(object, value);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Related

  1. setField(Object target, String name, Object value)
  2. setField(Object target, String name, Object value)
  3. setField(Object target, String name, Object value)
  4. setField(Object target, String name, Object value)
  5. setField(Object targetObject, String fieldName, Object value, boolean failIfError)
  6. setField(String field, Object value)
  7. setField(String fieldName, Object instance, Class instanceClass, Object value)
  8. setField(String fieldName, Object instance, Object value)
  9. setField(String name, Object target, Object value)