修改String 字符串

    public static void main(String[] args) throws Exception {


        String s = "hello word";

        Field va = String.class.getDeclaredField("value");
        va.setAccessible(true);

        char[] c = (char[]) va.get(s);

        c[1] = 'A';

        System.out.println(s);
}

你可能感兴趣的:(修改String 字符串)