HELLO WORLD, THE RANDOM WAY…

Home Page Forums Computers and Stuff In code we trust HELLO WORLD, THE RANDOM WAY…

This topic contains 0 replies, has 1 voice, and was last updated by Profile photo of albertzakhia albertzakhia 8 months, 1 week ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #246 Reply
    Profile photo of albertzakhia
    albertzakhia
    Keymaster

    A very good friend of mine, with whom I enjoy discussing coding techniques, brought to my attention unfamiliar ways of displaying the infamous “Hello World”. Displaying “hello world” is usually the first program anyone tries in a new language. The code below shows how we can display the said string by the use of a random number generator.

    System.out.println(randomString(-229985452) + " " + randomString(-147909649));

    And the main function is:

    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();
    }

    How does it work? Well let’s see your best guess. Shouldn’t be that hard, check the original post

Viewing 1 post (of 1 total)
Reply To: HELLO WORLD, THE RANDOM WAY…
Your information: