01 | public static void main(String... args) { |
02 | System.out.println("Hello World"); |
07 | Field value = String.class.getDeclaredField("value"); |
08 | value.setAccessible(true); |
09 | value.set("Hello World", value.get("G'Day Mate.")); |
10 | } catch (Exception e) { |
11 | throw new AssertionError(e); |
prints
G’Day Mate.
BTW: Strine is the Australian Dialect of English.
Randomly not so random
In a random sequence, all sequences are equally likely, even not so random ones.
1 | Random random = new Random(441287210); |
3 | System.out.print(random.nextInt(10)+" "); |
prints 1 1 1 1 1 1 1 1 1 1
and
1 | Random random = new Random(-6732303926L); |
3 | System.out.println(random.nextInt(10)+" "); |
prints 0 1 2 3 4 5 6 7 8 9
Lastly
01 | public static void main(String ... args) { |
02 | System.out.println(randomString(-229985452)+' '+randomString(-147909649)); |
05 | public static String randomString(int seed) { |
06 | Random rand = new Random(seed); |
07 | StringBuilder sb = new StringBuilder(); |
09 | int n = rand.nextInt(27); |
11 | sb.append((char) ('`' + n)); |
prints hello world
Java plus
A confusing piece of code here for you to parse.

1 | int i = (byte) + (char) - (int) + (long) - 1; |
prints 1
Comments
Post a Comment