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

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

Description

set Field Value

License

Open Source License

Declaration

public static void setFieldValue(String fieldName, int fieldValue, Object board) 

Method Source Code


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

import java.lang.reflect.Field;

public class Main {
    public static void setFieldValue(String fieldName, int fieldValue, Object board) {
        Field field;/*from  w w w . j a  v a2s  . c  o m*/
        try {
            field = board.getClass().getDeclaredField(fieldName);
            field.setAccessible(true);
            field.set(board, fieldValue);
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        } catch (SecurityException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}

Related

  1. setFieldValue(Object target, String fieldName, Object fieldValue)
  2. setFieldValue(Object target, String fieldName, Object value)
  3. setFieldValue(Object target, String fieldName, Object value)
  4. setFieldValue(Object target, String fieldName, String fieldValue)
  5. setFieldValue(Object target, String fname, Class ftype, Object fvalue)
  6. setFieldValue(String inField, Object inObject, Object inValue)
  7. setFieldValue(String name, Object instance, int value, Class cl)
  8. setFieldValue(String name, String obfuscatedName, Class clazz, Object object, Object value)
  9. setFieldvalue(T instance, E value, Field field)