小编Sri*_* KK的帖子

Cannot set Boolean value through reflection

I am not able to set a Boolean value to a field using Java reflection. The field data type is java.lang.Boolean. however, I am able to set the value if the data type is primitive type i.e boolean.

Here is a simple VO with Boolean type and primitive type:

public class TestVO {
    private Boolean bigBoolean;
    private boolean smallBoolean;
}
Run Code Online (Sandbox Code Playgroud)

Here is my java reflection code:

public class TestClass {
    public static void main(String args[])
            throws IllegalArgumentException, IllegalAccessException, …
Run Code Online (Sandbox Code Playgroud)

java reflection

5
推荐指数
1
解决办法
2515
查看次数

标签 统计

java ×1

reflection ×1