How to Generate Unique ID in Java (Integer)?

后端 未结 9 1506
生来不讨喜
生来不讨喜 2020-12-06 04:11

How to generate unique ID that is integer in java that not guess next number?

9条回答
  •  暖寄归人
    2020-12-06 04:58

    How unique does it need to be?

    If it's only unique within a process, then you can use an AtomicInteger and call incrementAndGet() each time you need a new value.

提交回复
热议问题