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.


/*from   www. j a  v  a  2 s  .  com*/
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.