LuVx21
6/22/2018 - 9:29 AM

final field

Field nameField = OneCity.class.getDeclaredField("name");

Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(nameField, nameField.getModifiers() & ~Modifier.FINAL);

nameField.setAccessible(true);
nameField.set(null, "Shenzhen");
System.out.println(OneCity.getName());