Java Reflection Field Set setField(final Object obj, final String fieldName, final int value)

Here you can find the source of setField(final Object obj, final String fieldName, final int value)

Description

set Field

License

Open Source License

Declaration

private static void setField(final Object obj, final String fieldName, final int value) 

Method Source Code


//package com.java2s;
// Licensed under the MIT license. See License.txt in the repository root.

import java.lang.reflect.Field;

public class Main {
    private static void setField(final Object obj, final String fieldName, final int value) {
        try {//  www. j a  v a2 s .c o m
            final Field field = obj.getClass().getField(fieldName);
            field.set(obj, new Integer(value));
        } catch (final Throwable t) {
            // ignore
        }
    }
}

Related

  1. setField(Field field, U instance, Object value)
  2. setField(final Field field, final Object instance, final Object value)
  3. setField(final Field field, final Object object, final Object value)
  4. setField(final O object, final String fieldName, final V value)
  5. setField(final Object instance, final String fieldName, final T value)
  6. setField(final Object obj, final String fieldName, final Object value)
  7. setField(final Object obj, final String name, final Object value)
  8. setField(final Object obj, final String variableName, final Object variableValue)
  9. setField(final Object object, final String name, final Object value)