File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Arrays

 
Nickk Singhal
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to generate random number without using random class
 
Joanne Neal
Rancher
Pie
Posts: 3742
16
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should read NotACodeMill and then update your post.

NB - this was a reply to the original post which was just a question copied from a book/exam paper/whatever and if i remember properly had nothing to do with random numbers.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could implement your own random number generator. But beware that it is not easy to create "good" random numbers (random numbers which are truly random, or which at least have a statistical distribution that comes close to being really random). Several algorithms have been invented to generate pseudo-random numbers; do some research to learn more about them.
 
Rob Spoor
Sheriff
Pie
Posts: 20393
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or just use Math.random(). It generates a double value between 0.0 (inclusive) and 1.0 (exclusive), so multiply it by X and cast to int to get an int value between 0 (inclusive) and X (exclusive).
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic