Results 1 to 2 of 2

Thread: random seed

  1. #1
    ahmed80 is offline Member
    Join Date
    Jan 2011
    Posts
    8
    Rep Power
    0

    Default random seed

    hi
    i want to creatE identical random number using identical seed.
    Random rand = new Random();
    long rseed = rand.nextLong();
    rand.setSeed(rseed);

    THEN I WILL PASS RAND TO OTHER FUNCTION:
    Random chRandom1 = new Random();
    chRandom1.setSeed(rand.nextLong());

    i am confused what are the output for these

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Well, that's not the way to do it. Simply define a long (any value you want) and use that number as the parameter for the Random(long) constructor for both variables.

Similar Threads

  1. Random
    By Feilin in forum New To Java
    Replies: 4
    Last Post: 08-15-2010, 04:49 PM
  2. Replies: 14
    Last Post: 10-19-2009, 11:57 AM
  3. Replies: 8
    Last Post: 04-19-2009, 06:50 PM
  4. Using Random
    By razmyasdfg in forum CLDC and MIDP
    Replies: 1
    Last Post: 07-27-2008, 11:47 PM
  5. random numbers without random class`
    By carlos123 in forum New To Java
    Replies: 4
    Last Post: 01-17-2008, 11:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •