mercredi 28 décembre 2016

Why I obtain the same number with Random Run?

I am following a book and in this code:

    Random rand = new Random(47);
    int i, j, k;
    j = rand.nextInt(100) + 1;
    System.out.println("j : " + j);
    k = rand.nextInt(100) + 1;
    System.out.println("k : " + k);

I have the same number in output of the book, that is:

j : 59
k : 56

If I use

Random rand = new Random();

without 47 Random Class produces random number and it's ok, but why if I put inside the number 47 joined with j = rand.nextInt(100) + 1; Why I obtain the same output of the book? Thank you




Aucun commentaire:

Enregistrer un commentaire