Java: Can (new Random()).nextInt(5) always return the same number?

后端 未结 6 1621
温柔的废话
温柔的废话 2020-12-11 08:57

Sometimes this piece of code always returns the same number (and sometimes it works fine):

(new Random()).nextInt(5)

I have suspicions wher

6条回答
  •  攒了一身酷
    2020-12-11 09:18

    ...Sometimes this piece of code [..] returns the same number (and sometimes it works fine)...

    So it works randomly??? :) :) :)

    Ok, ok, downvote me now!!

提交回复
热议问题