javauniqueidentifieruid

How to Generate Unique ID in Java (Integer)?


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


Solution

  • 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.