vendredi 21 octobre 2016

Generate random long within a range? (Java)

I am having issues generating a random long within a range (lets say between 'min' and 'max')

I know for integers it would work similar to the following:

random rand = new Random();

value = rand.nextInt((max-min)+1)+min;

I can not seem to find anything for doing this with longs and rand.nextLong((max-min)+1) + min does not seem to have the same functionality. It seems to be that nextLong() will not accept any parameters. Any ideas?




Aucun commentaire:

Enregistrer un commentaire