• Post Reply Bookmark Topic Watch Topic
  • New Topic

Random number generation starting from and between  RSS feed

 
rudresh kumar
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI all,

I would like to know how to generate random numbers (3 numbers) starting from 500 to 1000, i have tried with random class but it does not provide with min and max limit of the numbers to be generated.

Kindly let me know how can we do this

Thanks
Rudresh
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The general approach would be to use Random.nextInt(501) -which gives you random numbers between 0 and 500-, and then to add 500 to that.
[ September 11, 2007: Message edited by: Ulf Dittmer ]
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!