'Java 8 Modify Fields with reflections
I have have a problem with this field:
private final String name = "test";
I want to modify it with reflections, but it doesn't work.
Field field = Test.class.getDeclaredField("name");
field.setAccessible(true);
field.set(OBJECT, "Paul");
But after this code,... the field is the same.
If I create the field with the following code:
private final String name;
public Test() {
name = "test";
}
It will work..., but not with the first code :( Is there a way to do it with the example below? Any help?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
