Generate Unique ID Java

Generate Unique ID Java

Before Java 5 generating Unique Id was little strenuous process where people used many different logic to generate it. Here we will use java.util.UUID to generate unique Id.

  • GenerateUniqueID.java:
package com.javahonk;

import java.util.UUID;

public class GenerateUniqueID {

	public static void main(String[] args) {

		UUID uuid = UUID.randomUUID();
		System.out.println("Generated unique id: " + uuid);
	}
}
  • Output:

Generate Unique ID Java

  • For more information on  java.util.UUID please visit oracle documentation here

Leave a Reply

Your email address will not be published. Required fields are marked *