How to generate UUID in java ?

java.util.UUID class represents an immutable universally unique identifier (UUID). Below example generates a 128 bit value using UUID.

package com.pretechsol;
import java.util.UUID;
public class UUIDExample {
	public static void main(String[] args) {
			System.out.println(UUID.randomUUID());
		}
}

Output



4a6bfc5d-8ce0-41a0-830c-e6db704fe58a


No comments:

Post a Comment

12 classic String-based Java interview questions with simple explanations and code.

  1️⃣ Check if a String is a Palindrome Problem Given a string, check if it reads the same forward and backward. Example: "madam...

Featured Posts