As you can see here (using Mike Harrah excellent sxr ), Scala Random simply delegates to the base java.util.Random called self .
As others have pointed out, the default range is between Integer.MIN_VAL and Integer.MAX_VAL , in other words, any Integer is possible, including negative ones.
If you only want a positive range, you can use the overloaded nextInt method, which takes an argument, for example:
Random.nextInt(Integer.MAX_VALUE);
According to the docs:
Returns a pseudo-random uniformly distributed int value between 0 (inclusive) and the specified value (exception), taken from this sequence of random number generators.
Pablo fernandez
source share