简体   繁体   中英

I need to generate A 32bit random and unique number in hex representation

Following code is what I have done so far

    Random randomeNum =  new Random();
    int n = randomeNum.nextInt();
    System.out.println(Integer.toHexString(n));

Is this a correct way doing it?

您可以使用UUID生成32位随机十六进制数。

 UUID id=randomUUID();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM