Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

simple random number generator  RSS feed

 
Ashish chandra
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you please healp me create a really simple random number generator with numbers from 1 to 10 please. thank you
[ October 06, 2007: Message edited by: Ashish chandra ]
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16026
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at the documentation of the class java.util.Random.
 
Markus Hopper
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use a static random member
with random.nextLong() or random.nextInt(bound)
with jdk1.5
greetings, Markus
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, we forgot to say: Welcome to the ranch!

If you're making a number generator for an assignment or just to do it, Google for algorithms. The good ones are not simple! If you need one for any kind of professional or serious use, try the library methods mentioned above. They're much better (more random) than anything we could make up.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!