Java UUID.randomUUID() method example

Java UUID.randomUUID() method example

By technicalkeeda, Views 434, Date 21-Feb-2018

In this tutorial, You will learn how to generate random UUID number. Java UUID.randomUUID() method returns a randomly generated UUID.

tags Java

Static factory to retrieve a type 4 (pseudo randomly generated) UUID. The UUID is generated using a cryptographically strong pseudo random number generator.


public static UUID randomUUID()


A randomly generated UUID.

Java UUID randomUUID() example

  • Create random UUID by invoking static method UUID.randomUUID();
  • Print the randomly generated UUID's.
package com.technicalkeeda;

import java.util.UUID;

public class App {

    public static void main(String[] args) {

        UUID randomUUID = UUID.randomUUID();

        System.out.println("Random UUID :-  " + randomUUID);
        System.out.println("Random UUID :-  " + UUID.randomUUID());
        System.out.println("Random UUID :-  " + UUID.randomUUID());
        System.out.println("Random UUID :-  " + UUID.randomUUID());



Random UUID :-  860c5c50-274f-4cb9-9735-c7cc58b9d701
Random UUID :-  d7660de1-da71-48a4-81db-494a002b5b5e
Random UUID :-  6579cf0a-8a51-4b4e-bda6-f4b9764c2d01
Random UUID :-  d33c697d-677d-4178-8e86-60880edabd05

Suggested Posts



Hi there! I am founder of and programming enthusiast. My skills includes Java,J2EE, Spring Framework, Nodejs, PHP and lot more. If you have any idea that you would want me to develop? Lets connect: yashwantchavan[at][]