A
Anand
hi plz tell me how to code a method that will randomly pick boolean
value 0 or 1
value 0 or 1
hi plz tell me how to code a method that will randomly pick boolean
value 0 or 1
Ashoka! said:Generate a random integer by using the random class <http://
java.sun.com/j2se/1.5.0/docs/api/java/util/Random.html> and then use
int bValue = randomInt % 2;
to get a o or 1 value.
Ashoka! said:Generate a random integer by using the random class <http://
java.sun.com/j2se/1.5.0/docs/api/java/util/Random.html> and then use
int bValue = randomInt % 2;
to get a o or 1 value.
Patricia said:If {0,1} is really wanted, why not use myRandom.nextInt(2)? Or if a
boolean is wanted, myRandom.nextBoolean()?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.