
-----------------------------------
Prince
Thu Feb 19, 2004 11:07 am

random integers
-----------------------------------
how do u get them? i had sum code but it disappeared :?

-----------------------------------
wtd
Thu Feb 19, 2004 7:18 pm


-----------------------------------
import java.lang.*;
import java.io.*;
import java.util.*;

class Test
{
   long randomNumberSeed = System.currentTimeMillis();
   Random randomNumberGenerator = new Random(randomNumberSeed);
   int randomInt = randomNumberGenerator.nextInt();
}

See the Sun Java docs for the Random class.

-----------------------------------
Prince
Fri Feb 20, 2004 10:18 am


-----------------------------------
isnt there a simpler way :?

-----------------------------------
Tony
Fri Feb 20, 2004 2:12 pm


-----------------------------------
looks preaty simple to me... once you declear your randomNumGen, its just

randomNumberGenerator.nextInt(); 


-----------------------------------
rizzix
Fri Feb 20, 2004 5:08 pm


-----------------------------------
even simpler? hmm...

Math.random();


-----------------------------------
wtd
Fri Feb 20, 2004 6:18 pm


-----------------------------------
even simpler? hmm...

Math.random();


Yeah, I knew someone would beat me to that answer, so I posted the other answer.  ;)

Really, though, use either one, but know the Random class.  It's more powerful and flexible than Math.random().
