Java UUID, javaUUID

Source: Internet
Author: User

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
.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.