Here you can find the source of setField(String field, Object object, Object value)
public static void setField(String field, Object object, Object value)
//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(); } } }