Generate Random UUID in Java

Tags: UUID Random

In this Java core tutorial, we learn how to use java.util.UUID class in Java to generate a random universally unique identifier (UUID).

In the following Java program, we show how to use UUID.randomUUID() static method to generate a new random UUID value.

import java.util.UUID;

public class GenerateRandomUUID {
    public static void main(String[] args) {

        UUID uuid = UUID.randomUUID();

        String uuidString = uuid.toString();

The output is:

Happy Coding 😊