Java Data Type Tutorial - Java UUID.randomUUID()








Syntax

UUID.randomUUID() has the following syntax.

public static UUID randomUUID()

Example

In the following code shows how to use UUID.randomUUID() method.

// w  w  w . j  a  v a2 s  .  c o  m
import java.util.UUID;

public class Main {
   public static void main(String[] args) {
      // creating UUID      
      UUID uid = UUID.randomUUID();     
        
      System.out.println("Random UUID value: "+uid);    
   }    
}

The code above generates the following result.