Is there a way to generate a random UUID, which consists only of numbers?

后端 未结 10 1543
一生所求
一生所求 2020-12-09 09:27

Java\'s UUID class generates a random UUID. But this consists of letters and numbers. For some applications we need only numbers. Is there a way to generate random UUID that

10条回答
  •  情深已故
    2020-12-09 09:47

    Although the original poster of this question marked @Jigar Joshi's question as the best answer, I'd like to add that there is a rationale to use UUIDs rather than random numbers in certain cases. The difference is that UUIDs are (universally) unique (hence the name) while random numbers are not. It's just a question of probability whether you get the same number twice or even more often when generating random numbers, but this will never happen with UUIDs. Therefore, I'd consider @Chris Eibl's answer as the best one.

提交回复
热议问题