本文翻译自:Getting random numbers in Java [duplicate]
Possible Duplicate: 可能重复:
Java: generating random number in a range Java:生成一定范围内的随机数
I would like to get a random value between 1 to 50 in Java. 我想在Java中获得1到50之间的随机值。
How may I do that with the help of Math.random();
我该如何在Math.random();
的帮助下做到这一点Math.random();
? ?
How do I bound the values that Math.random()
returns? 如何绑定Math.random()
返回的值ÿ