Java UUID, javaUUID
UUID (Universally Unique Identifier) is a globally Unique Identifier, which is a number generated on a machine. It ensures that all machines in the same time and space are Unique. According to the standards set by the Open Software Foundation (OSF), ethernet card addresses, nanoseconds, chip ID codes, and many possible numbers are used. The combination of the following parts: the current date and time (the first part of UUID is related to the time. If you generate a UUID in seconds, the first part is different and the rest are the same), the clock sequence, and the globally unique IEEE machine identification number (if there is a nic, it is obtained from the NIC, and no Nic is obtained in other ways ), the unique defect of UUID is that the generated result string is long.
UUID is a 128-bit long number, which is generally expressed in hexadecimal notation. The core idea of an algorithm is to generate a UUID Based on the machine's Nic, local time, and a random number. Theoretically, if a machine generates 10000000 UUID every second, it can ensure (in probability) that there will be no duplicates in 3240. In this way, each user can create a UUID that does not conflict with others. In this case, duplicate names are not required during database creation.
UUID is a new class in 1.5. in java. util, it can generate a globally unique ID.
Package UUID;
Import java. util. UUID;
Public class test {
Public static void main (String [] args ){
String uuid = UUID. randomUUID (). toString ();
System. out. println (uuid );
}
}
The following is the result of three operations
D0cd48ef-313a-405c-ac76-12cce5657dca
D7e1e24b-9574-4ea0-a08f-4cfa6965035f
C6b75eef-f6ca-4963-8c4f-26b72cb15eee
.