Name
UUID
Synopsis
This class is an immutable representation of 128-bit
Universal Unique
Identifier, or UUID, which serves as an identifier that is (with very
high probability) globally unique. Create a UUID based on random bits
with the randomUUID( )
factory method. Create a
UUID based on the MD5 hash code of an array of bytes with the
nameUUIDFromBytes( )
factory method. Or create a
UUID by parsing a string with the fromString( )
factory method. The standard string format of a UUID is 32
hexadecimal digits, broken into five hyphen-separated groups of 8, 4,
4, 4, and 12 digits. For example:
7cbf3e1a-d521-40ac-87f1-e28b17530f60
Both lowercase and uppercase hex digits are allowed. The
toString( )
method converts a UUID object to a
string using this standard format. You can also create a UUID object
by explicitly passing the 128 bits in the form of two
long
values to the UUID( )
constructor, but this option should be used only if you are
intimately familiar with the relevant UUID standards.
The toString( )
and equals( )
methods define the most common operations on a UUID. The
UUID
class implements the
Comparable
interface and defines an ordering for
UUID
objects. Note, however, that the ordering
does not represent any meaningful property, such as generation order,
of the underlying bits.
Various accessor methods provide details about the bits of a
UUID
, but these details are rarely useful.
getLeastSignificantBits( )
and
getMostSignificantBits( )
return the bits of a
UUID as two long ...
Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.