Here you can find the source of setField(final Object obj, final String fieldName, final int value)
private static void setField(final Object obj, final String fieldName, final int value)
//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 } } }