This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes save random numbers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "save random numbers" Watch "save random numbers" New topic

save random numbers

s dont

Joined: Oct 27, 2003
Posts: 1
below is the coding for random numbers

public class Random {public static void main(String[] args) {java.util.Random rand = new java.util.Random();for (int i = 0; i < 20; i++) {System.out.println(rand.nextInt(10));}}}

how do i save the random numbers???
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937
how do i save the random numbers???
Depends where you want to save them. Database? Memory? Text File? Serialized data?
Tom Blough
Ranch Hand

Joined: Jul 31, 2003
Posts: 263
If you seed the generator with a known value, you can re-generate the SAME string of "random" numbers any time by just reseeding the generator with the same number again. That way, you do not need to save the generated numbers in the first place.
[ October 27, 2003: Message edited by: Tom Blough ]

Tom Blough<br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr>Cum catapultae proscriptae erunt tum soli proscripti catapultas habebunt.<hr></blockquote>
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 984

I sure hope that you don't actually write your code like that, all on one line.

Please ignore post, I have no idea what I am talking about.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: save random numbers
Similar Threads
Question on java.util.Random
Random String (Hash)
How can I fix the size of randomly generated numbers ?
random numbers
A number generation program....