CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2005
    Posts
    47

    Thumbs up Basic question on random

    Hello friend (suppose so, still depends anyway, ^^)
    Could you tell me how random in java is implemented ? Is it the same as C's rand() ?
    Thanks,


  2. #2
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104

    Re: Basic question on random

    you can use Math.random() which returns a number n such that 0 <= n < 1

    or you can use the Random class, which provides for better control of random sequences, ranges, and ability to repeat a sequence
    http://java.sun.com/j2se/1.4.2/docs/...il/Random.html
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

  3. #3
    Join Date
    Feb 2004
    Location
    USA - Florida
    Posts
    729

    Re: Basic question on random

    There's an option, when you install the J2SE SDK, to also include the source code for the Java library during installation. After installation, open the zip file called src.zip in the folder where you chose to install SDK.
    Hungarian notation, reinterpreted? http://www.joelonsoftware.com/articles/Wrong.html

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured