Issue
I need to genarate a random number with exactly 6 digits in Java. I know i could loop 6 times over a randomizer but is there a nother way to do this in the standard Java SE?
Solution
Generate a number in the range from 100000 to 999999.
// pseudo code
int n = 100000 + random_float() * 900000;
For more details see the documentation for Random
Answered By - Bombe
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.