Here you can find the source of setField(Field field, Object classWithField, Object value)
Parameter | Description |
---|---|
Field | The field to set. |
Object | The value to set. |
public static void setField(Field field, Object classWithField, Object value)
//package com.java2s; //License from project: Creative Commons License import java.lang.reflect.Field; public class Main { /**//from ww w .j a v a 2 s. c o m * @param Field The field to set. * @param Object The class of the field. * @param Object The value to set. */ public static void setField(Field field, Object classWithField, Object value) { try { field.set(classWithField, value); } catch (IllegalArgumentException | IllegalAccessException e) { e.printStackTrace(); } } }