Created
March 8, 2013 13:43
-
-
Save kevinslin/5116515 to your computer and use it in GitHub Desktop.
#java #cool "Random" Hello world
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// source: http://stackoverflow.com/questions/15182496/why-does-this-code-print-hello-world?newsletter=1&nlcode=83359%7c512e | |
System.out.println(randomString(-229985452) + " " + randomString(-147909649)); | |
public static String randomString(int i) | |
{ | |
Random ran = new Random(i); | |
StringBuilder sb = new StringBuilder(); | |
for (int n = 0; ; n++) | |
{ | |
int k = ran.nextInt(27); | |
if (k == 0) | |
break; | |
sb.append((char)('`' + k)); | |
} | |
return sb.toString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment