random generator in java

Discussion in 'OT Technology' started by suitcase, Apr 16, 2004.

  1. suitcase

    suitcase New Member

    Joined:
    Feb 2, 2004
    Messages:
    4
    Likes Received:
    0
    Is there any way to create multiple instances of Random with a single seed so that the multiple instances produce different numbers?
     
  2. Nocera

    Nocera ...

    Joined:
    Aug 9, 2000
    Messages:
    1,307
    Likes Received:
    0
    Location:
    Long Island, NY
    Try using the date to seed it. It's not truly random but for most purposes it suffices.

    Random r = new Random((new java.util.Date).getTime());
     
  3. ChosenGSR

    ChosenGSR Mama always said you'd be the chosen one

    Joined:
    Oct 24, 2001
    Messages:
    50,982
    Likes Received:
    214
    Location:
    HoCo, MD
    yep. using the time is a good seed.
     

Share This Page