+ 3

Random integers in Java

How to generate random integers between a interval

17th Apr 2017, 12:51 AM
Anibal Lopes
3 odpowiedzi
+ 6
Another way from 0 to some number: Math.random() * max; No imports required.
17th Apr 2017, 4:16 AM
Rrestoring faith
Rrestoring faith - avatar
+ 5
Random r = new Random(); int hi = 10; int lo = 1; int number = r.nextInt(hi-lo) + lo;
17th Apr 2017, 12:55 AM
LordHill
LordHill - avatar
+ 4
random.nextInt( max - min + 1 ) + min
17th Apr 2017, 1:10 AM
⏩▶Clau◀⏪
⏩▶Clau◀⏪ - avatar