Auf stackoverflow.com schreibt Benutzer abcXYZ:
I came across this piece of code, and found it rather interesting. The following print statement would print „hello world“. Could anyone explain this?
public static void main(String[] argv) {
System.out.println(randomString(-229985452) + " " + randomString(-147909649));
}
public static String randomString(int i) {
Random ran = new Random(i);
StringBuilder sb = new StringBuilder();
while (true) {
int k = ran.nextInt(27);
if (k == 0)
break;
sb.append((char)('`' + k));
}
return sb.toString();
}
In den Antworten gibt auch gleich eine informationstheoretische Erklärung, die nahelegt, dass es mit „Hello, World“ vermutlich nicht funktioniert hätte (von Clemens gefunden).