// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
public class StringFun {
    public static void main(String[] args) throws Exception {
        String s1 = "ABCEF";
        System.out.printf("s1=%s\n", s1);
        String s2 = s1.substring(1, 4);
        System.out.printf("s2=%s\n", s2);
        // start dirty
        // note: only access s1 not s2
        java.lang.reflect.Field value = String.class.getDeclaredField("value");
        value.setAccessible(true);
        char[] buf = (char[])value.get(s1);
        buf[2] = 'X';
        // end dirty
        System.out.printf("s1=%s\n", s1);
        System.out.printf("s2=%s\n", s2);
    }
}
