Math.random() explanation

后端 未结 5 1590
一个人的身影
一个人的身影 2020-11-22 07:02

This is a pretty simple Java (though probably applicable to all programming) question:

Math.random() returns a number between zero and on

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 07:32

    The Random class of Java located in the java.util package will serve your purpose better. It has some nextInt() methods that return an integer. The one taking an int argument will generate a number between 0 and that int, the latter not inclusive.

提交回复
热议问题