AG UUID

Java UUID

How to generate a standard UUID (typically v4) in Java, using the standard library or a widely used package.

Code

Main.java
import java.util.UUID;

UUID id = UUID.randomUUID();  // v4
String s = id.toString();
Most languages provide v4 (random) out of the box, while v7 or ULID may require a separate library.

View version reference →