Author |
Message |
Prince
![](http://www.angelfire.com/hiphop3/m-unit_hustla/images/fxckpare.jpg)
|
Posted: Thu Feb 19, 2004 11:07 am Post subject: random integers |
|
|
how do u get them? i had sum code but it disappeared ![Confused Confused](http://compsci.ca/v3/images/smiles/icon_confused.gif) |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
wtd
|
Posted: Thu Feb 19, 2004 7:18 pm Post subject: (No subject) |
|
|
code: | 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. |
|
|
|
|
![](images/spacer.gif) |
Prince
![](http://www.angelfire.com/hiphop3/m-unit_hustla/images/fxckpare.jpg)
|
Posted: Fri Feb 20, 2004 10:18 am Post subject: (No subject) |
|
|
isnt there a simpler way ![Confused Confused](http://compsci.ca/v3/images/smiles/icon_confused.gif) |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Fri Feb 20, 2004 2:12 pm Post subject: (No subject) |
|
|
looks preaty simple to me... once you declear your randomNumGen, its just
code: |
randomNumberGenerator.nextInt();
|
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
rizzix
|
Posted: Fri Feb 20, 2004 5:08 pm Post subject: (No subject) |
|
|
even simpler? hmm...
|
|
|
|
|
![](images/spacer.gif) |
wtd
|
Posted: Fri Feb 20, 2004 6:18 pm Post subject: (No subject) |
|
|
rizzix wrote:
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(). |
|
|
|
|
![](images/spacer.gif) |
|