int first = ( int )( Math.random() * 1000000 ) ;
int second = ( int )( Math.random() * 10000 ) ;
String final = first + "" + second ;
Main Topics
Browse All Topics Hi Experts!
I would like to generate a particular 10 digit number. The first 4 digits are related to userID and the rest 6 should be "random" or ordered but they must be synchronized since they are used as an unique identifiers. The ideea is to split the code in two. One who generates the 6 digits and later on I can add the 4 digits. How one can do that?
Thanks!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I never did explain my code ...
It takes the hashcode of a string of the current system time in milliseconds, and reverses it (the extra milliseconds being evident at the right-hand end of the system time), using the first 6 of those positions as the unique result. If you put that code in a loop, you could generate about a quarter million values an hour. You can then iterate those values, prepending your UID complexion.
Business Accounts
Answer for Membership
by: CEHJPosted on 2008-03-07 at 03:57:47ID: 21069145
You need to keep a record of numbers generated. You could use a Set, serialized if necessary