Random类的常用方法

1、nextBoolean():

随机返回true或false

2、nextInt(int bound):

随机返回0到bound之间的整数(不包括bound)

如:nextInt(10)返回0-9之间的随机数,nextInt(100)返回0-99之间的随机数

3、nextDouble():

返回(0, 1)开区间内的小数,精度为16位

4、nextFloat():

返回(0, 1)开区间内的小数,精度为8位

 

5、应用:

 

posted @ 2018-03-16 15:16  渡劫锦官城  阅读(898)  评论(0编辑  收藏  举报