aspose file tools*
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
JavaRanch » Java Forums » Java » Java in General
Bookmark "save random numbers" Watch "save random numbers" New topic
Author

save random numbers

s dont
Greenhorn

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: 986

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: save random numbers