方法一:Random.nextInt()
1 | Random random = new Random(); |
方法二:Random.nextInt(bound)
1 | num = random.nextInt(11);//生成0~(bound-1)之内的整数 |
方法三:Math.Random()
1 | int max = 100; |
1 | Random random = new Random(); |
1 | num = random.nextInt(11);//生成0~(bound-1)之内的整数 |
1 | int max = 100; |