Java Random number between 100 and 500 which is a multiple of 10 -


i want generate random number between 2 numbers multiples of 10. example, between 100 , 500, want generate uniform distribution of 110, 120 ... 490, 500.

i think better use random.nextint() per this post. not sure how that.

you can use function.

public int random() {      random r=new random();      return (r.nextint(41)+10)*10; } 

read math.random() versus random.nextint(int)

random.nextint(n) both more efficient , less biased math.random() * n


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -