uuid java code example
Example 1: java uuid from string
import java.utils.UUID;
UUID uuid = UUID.fromString(string);
Example 2: java uuid
import java.util.UUID;
public class RandomStringUUID {
public static void main(String[] args) {
UUID uuid = UUID.randomUUID();
String randomUUIDString = uuid.toString();
System.out.println("Random UUID String = " + randomUUIDString);
System.out.println("UUID version = " + uuid.version());
System.out.println("UUID variant = " + uuid.variant());
}
}
Example 3: java uuid
String id = UUID.randomUUID().toString();