Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.
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
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
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) ...
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.