UUID getLeastSignificantBits() Method in Java with Examples
The UUIDs are 128-bit values. The getLeastSignificantBits() Method of UUID class in Java is used to get the least significant 64 bits of this UUID.
Syntax:
public long getLeastSignificantBits()
Parameters: The method does not take any parameters.
Return Value: The method returns an integer value which is the least significant 64 bit of this 128 valued UUID.
Below programs illustrate the working of getLeastSignificantBits() method:
Program 1:
import java.util.*;
public class UUID_Demo {
public static void main(String[] args)
{
UUID UUID_1
= UUID
.fromString(
"58e0a7d7-eebc-11d8-9669-0800200c9a66" );
System.out.println( "UUID: "
+ UUID_1);
System.out.println( "The value is: "
+ UUID_1.clockSequence());
System.out.println( "The least significant 64 bit: "
+ UUID_1
.getLeastSignificantBits());
}
}
|
Output:
UUID: 58e0a7d7-eebc-11d8-9669-0800200c9a66
The value is: 5737
The least significant 64 bit: -7608541298835023258
Program 2:
import java.util.*;
public class UUID_Demo {
public static void main(String[] args)
{
UUID UUID_1
= UUID
.fromString(
"58e0a7d7-eebc-11d8-9669-0800200c9a66" );
System.out.println( "UUID: "
+ UUID_1);
System.out.println( "The value is: "
+ UUID_1.clockSequence());
System.out.println( "The least significant 64 bit: "
+ UUID_1.getLeastSignificantBits());
}
}
|
Output:
UUID: 58e0a7d7-eebc-11d8-9669-0800200c9a66
The value is: 5737
The least significant 64 bit: -7608541298835023258
Last Updated :
27 Dec, 2018
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...