method for randomly selecting boolean value

Discussion in 'Java' started by Anand, Mar 9, 2007.

  1. Anand

    Anand Guest

    hi plz tell me how to code a method that will randomly pick boolean
    value 0 or 1
    Anand, Mar 9, 2007
    #1
    1. Advertising

  2. Anand

    Eric Sosman Guest

    Anand wrote On 03/09/07 17:27,:
    > hi plz tell me how to code a method that will randomly pick boolean
    > value 0 or 1


    Not possible: The only boolean values are true and false.

    If you can modify the requirements a little, though, you
    might be able to generate boolean values by using Math.rand()
    and a comparison, or by using java.util.Random#nextBoolean().
    It's astonishing what you can find in the JavaDoc, once you
    take the dreaded step of consulting it.

    --
    Eric Sosman, Mar 9, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anand
    Replies:
    5
    Views:
    497
    Alex Hunsley
    Mar 10, 2007
  2. Generic Usenet Account
    Replies:
    9
    Views:
    344
    James Kanze
    Jul 1, 2007
  3. Paul
    Replies:
    3
    Views:
    98
  4. George

    Randomly selecting Variables

    George, Jun 6, 2005, in forum: Perl Misc
    Replies:
    5
    Views:
    127
    Scott Bryce
    Jun 7, 2005
  5. Metre Meter
    Replies:
    7
    Views:
    366
    Metre Meter
    Aug 6, 2010
Loading...

Share This Page