Strine translator

Translating to Strine ;)
    public static void main(String... args) {
        System.out.println("Hello World");
    }

    static {
        try {
            Field value = String.class.getDeclaredField("value");
            value.setAccessible(true);
            value.set("Hello World", value.get("G'Day Mate."));
        } catch (Exception e) {
            throw new AssertionError(e);
        }
    }
prints
G'Day Mate.
BTW: Strine is the Australian Dialect of English.

Comments

  1. 1.- String is inmutable, but not that inmutable ;)

    String s = new String("Hello World");
    String r = " and goodbye";
    System.out.println(s+r);

    Prints: G'Day Mate. and goodbye

    2.- It's very important to manage the Java Security: Permissions in the Security Manager, ReflectPermission("suppressAccessChecks") permission according the javadoc for the setAccesible method in the Field class.

    ReplyDelete

Post a Comment

Popular posts from this blog

Why You Should Tune Code Before Your Garbage Collector

Asking multiple AI to optimise the same code

Which Doc Format is Best for AI Specifications?