Here you can find the source of setFieldValue(Object obj, Field field, Object value)
public static void setFieldValue(Object obj, Field field, Object value) throws IllegalArgumentException, IllegalAccessException
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import java.lang.reflect.Field; public class Main { public static void setFieldValue(Object obj, Field field, Object value) throws IllegalArgumentException, IllegalAccessException { field.setAccessible(true);//from www. j a v a 2 s . co m field.set(obj, value); } }