public static void main(String[] args) throws Exception {
String s = "ctx application";
Field field = String.class.getDeclaredField("value");
field.setAccessible(true);
byte[] value = (byte[]) field.get(s);
value[3] = '_';
System.out.println(s); // ctx_application
}
通过反射,可以修改String对象内容