HiveBrain v1.2.0
Get Started
← Back to all entries
snippetjavaCritical

Create a GUID / UUID in Java

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
uuidguidjavacreate

Problem

What are some of the best ways to create a GUID / UUID in Java?

Solution

Have a look at the UUID class bundled with Java 5 and later.

For example:

  • If you want a random UUID you can use the randomUUID method.



  • If you want a UUID initialized to a specific value you can use the UUID constructor or the fromString method.

Context

Stack Overflow Q#2982748, score: 396

Revisions (0)

No revisions yet.