Translate

четвер, 7 березня 2013 р.

HelloWorld in Java


Чудовий пост на StackOverflow
I came across this piece of code, and found it rather interesting. The following print statement would print "hello world". Could anyone explain this?
System.out.println(randomString(-229985452) + " " + randomString(-147909649));
And randomString() looks like this
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();
}


Немає коментарів:

Дописати коментар