Saturday, November 22, 2025
HomeLanguagesJavaUUID node() Method in Java with Examples

UUID node() Method in Java with Examples

The node() method of UUID class in Java is generally used to get the node value associated with this UUID.

Syntax:

public long node()

Parameters: This method does not take any parameter.

Return Value: This method returns an long value which is the node value associated with this UUID.

Exception: This method throws UnsupportedOperationException If this UUID is not a version 1 UUID

Below programs illustrate the working of node() method:

Program 1:




// Java code to illustrate node() method
  
import java.util.*;
  
public class UUID_Demo {
    public static void main(String[] args)
    {
  
        // Creating two UUIDs
        UUID UUID_1
            = UUID
                  .fromString(
                      "58e0a7d7-eebc-11d8-9669-0800200c9a66");
  
        // Displaying the UUID
        System.out.println("UUID: "
                           + UUID_1);
  
        // Displaying the node value
        System.out.println("The node value is: "
                           + UUID_1.node());
    }
}


Output:

UUID: 58e0a7d7-eebc-11d8-9669-0800200c9a66
The node value is: 8796630719078

Program 2:




// Java code to illustrate node() method
  
import java.util.*;
  
public class UUID_Demo {
    public static void main(String[] args)
    {
  
        // Creating two UUIDs
        UUID UUID_1
            = UUID
                  .fromString(
                      "5fc03087-d265-11e7-b8c6-83e29cd24f4c");
  
        // Displaying the UUID
        System.out.println("UUID: "
                           + UUID_1);
  
        // Displaying the node Value
        System.out.println("The node value is: "
                           + UUID_1.node());
    }
}


Output:

UUID: 5fc03087-d265-11e7-b8c6-83e29cd24f4c
The node value is: 145009316876108
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32407 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6784 POSTS0 COMMENTS
Nicole Veronica
11930 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11999 POSTS0 COMMENTS
Shaida Kate Naidoo
6907 POSTS0 COMMENTS
Ted Musemwa
7168 POSTS0 COMMENTS
Thapelo Manthata
6863 POSTS0 COMMENTS
Umr Jansen
6847 POSTS0 COMMENTS