jeudi 9 novembre 2017

new Random(seed) generates ordered sequence of numbers [duplicate]

This question already has an answer here:

There is interesting quiz which I didn't find answer yet

    Random random = new Random(-6732303926L);
    for (int i = 0; i < 10; i++) {
        int randomNumber = random.nextInt(10);
        System.out.print(randomNumber);
    }

OUTPUT: 0123456789

My question is not about why random generates the same output all time? It's clear from documentation and, for example, from this answer.

My question is why it generates ordered numbers? Could someone describe how does it work?




Aucun commentaire:

Enregistrer un commentaire