How to generate random UUID in Java

2014, Jul 03    

Hi there! Generating a random UUID is much more easier than you could ever imagine! I use the following block of code, whenever I’m in a need of more than ten: <pre class="brush:java">
for(int i = 0; i < 30; i++) {
System.out.println(UUID.randomUUID());
}
</pre> If things get difficult and time passes, working with UUIDs, you ‘ll probably get lost, if the way you chose to generate your UUID was “a bunch at a time”, like above, so you could either visit a site, like this or modify your program like below: <pre class="brush:java">
System.out.println(UUID.randomUUID());
</pre> Cheers!