This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

save random numbers

 
s dont
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do i save the random numbers???
Depends where you want to save them. Database? Memory? Text File? Serialized data?
 
Tom Blough
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I sure hope that you don't actually write your code like that, all on one line.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic