I wonder what is the meaning of above output. Esp like 5:6 etc.There is no 6. The output means that the value in the range 1 to 5 is :n
e.g.
random integer from 1 to 5:2
the random value generated in that range was 2
random integer:-2143199807
random integer:128861668
random integer:1688911854
random integer:-1021991149
random integer:69006493
random integer:110974251
random integer:846899949
random integer:1052181148
random integer:-1013327507
random integer:1169652165
random integer from 1 to 5:5
random integer from 1 to 5:1
random integer from 1 to 5:1
random integer from 1 to 5:5
random integer from 1 to 5:2
random integer from 1 to 5:2
random integer from 1 to 5:4
random integer from 1 to 5:5
random integer from 1 to 5:5
random integer from 1 to 5:4
I wonder what is the meaning of above output. Esp like 5:6 etc.There is no 6. The output means that the value in the range 1 to 5 is :n
random integer from 1 to 5:2
What are the practical uses, purpose of random integer values.
// generates a random int
for (int i = 0; i < 10; i++) {
anyRandomInt(random);
}
System.out.println();
// generates a random int in a range from low int to high int
for (int i = 0; i < 10; i++) {
anyRandomIntRange(random, 1, 5);
}
int randomInt = random.nextInt(high) + low;
random integer:-2143199807
random integer:128861668
random integer:1688911854
random integer:-1021991149
random integer:69006493
random integer:110974251
random integer:846899949
random integer:1052181148
random integer:-1013327507
random integer:1169652165
random integer from 1 to 5:5
random integer from 1 to 5:1
random integer from 1 to 5:1
random integer from 1 to 5:5
random integer from 1 to 5:2
random integer from 1 to 5:2
random integer from 1 to 5:4
random integer from 1 to 5:5
random integer from 1 to 5:5
random integer from 1 to 5:4
random.nextInt(high)
random.nextInt();
what is difference between below two lines belowThe javadoc for Random is pretty clear on this...
random.nextInt(high)
random.nextInt();
Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive) ...(Note the inclusive and exclusive in the above quote). So if for example 'high' = 8, it returns a random number that can have any value from the following... 0, 1, 2, 3, 4, 5, 6, or 7
Returns the next pseudorandom, uniformly distributed int value ... All 2^32 possible int values are produced with (approximately) equal probabilitySo this returns a random number in the full range that an int can represent,
turns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive) ...
Title | # Comments | Views | Activity |
---|---|---|---|
Exchange and Third Party application. | 8 | 59 | |
bunnyEars challenge | 6 | 62 | |
Close to having database queries displayed to Jlist, what am I missing? | 3 | 44 | |
Systems talking to each other | 5 | 108 |
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
16 Experts available now in Live!