Java Reflection Java Java API
java.lang.reflect.Field
public void setChar(Object obj, char c) throws IllegalArgumentException, IllegalAccessException
Sets the value of a field as a char on the specified object.
char
package com.logicbig.example.field;import java.lang.reflect.Field;public class SetCharExample { private char myChar; public static void main(String... args) throws NoSuchFieldException, IllegalAccessException { Field f = SetCharExample.class.getDeclaredField("myChar"); SetCharExample instance = new SetCharExample(); f.setChar(instance, 'z'); System.out.println(f.getChar(instance)); }}
z