Best way to generate a unique ID in java

前端 未结 2 1240
借酒劲吻你
借酒劲吻你 2021-01-21 04:29

What is the best way to generate a unique ID in java. People generally use

String id = System.currentTimeMillis+ someStaticCounter;

But this a

相关标签:
2条回答
  • 2021-01-21 04:45

    How about UUID: http://java.sun.com/j2se/1.5.0/docs/api/java/util/UUID.html#randomUUID%28%29

    0 讨论(0)
  • 2021-01-21 04:49

    UUID.randomUUID()

    0 讨论(0)
提交回复
热议问题