Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Kaua Costa   on Feb 21 In Java Category.

  
Question Answered By: Alfonsine Miller   on Feb 21

You don't say which part of this is giving you trouble - i.e. is it the
generation of the random  number for the first run, or the storage of this random
number in a file for use by the next run, or working out whether it is the first
run of the program  (random number  wanted) or a subsequent run  (non-random number
wanted)? Please expand on where your problem  lies.

To hold the value between runs, you will need a file.

To work out if this is the first run of the program, probably the best way would
be to check whether the above file exists yet. If it doesn't, then it can be
assumed that this is the first run. If it does, simply read the number from the
last run, add 1 and write it back.

Share: 

 

This Question has 6 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Problem with random number in java Or get search suggestion and latest updates.


Tagged: