Java UUID.variant() method example

In this tutorial, You will learn how to get the variant number of this UUID.

The variant number describes the layout of the UUID. The variant number has the following meaning :-

  • 0 Reserved for NCS backward compatibility.
  • 2 IETF RFC 4122 (Leach-Salz), used by this class.
  • 6 Reserved, Microsoft Corporation backward compatibility.
  • 7 Reserved for future definition.


public int variant()


The variant number of this UUID.

Java UUID variant() example

  • Initialize the String String name = "d605a917-a9d4-44d1-a3ef-60e960a4b9b2";
  • UUID.fromString(name); It creates a UUID from the string standard representation.
  • uuid.variant(); It returns the variant number associated with this UUID.
package com.technicalkeeda;

import java.util.UUID;

public class App {

    public static void main(String[] args) {

        String name = "d605a917-a9d4-44d1-a3ef-60e960a4b9b2";
        UUID uuid = UUID.fromString(name);

        System.out.println("UUID variant is :- " + uuid.variant());


UUID variant is :- 2