import java.util.UUID; public class UUIDGenerator { public static void main(String[] args) { // Generate a random UUID UUID uuid = UUID.randomUUID(); System.out.println("UUID Generated: " + uuid.toString()); } }
import java.util.UUID; public class UUIDParser { public static void main(String[] args) { // Parse a UUID from a string String uuidString = "38400000-8cf0-11bd-b23e-10b96e4ef00d"; UUID uuid = UUID.fromString(uuidString); System.out.println("Parsed UUID: " + uuid.toString()); } }
import java.util.UUID; public class UUIDCreator { public static void main(String[] args) { // Create a UUID based on a name and namespace UUID uuid = UUID.nameUUIDFromBytes("Hello World".getBytes()); System.out.println("Created UUID: " + uuid.toString()); } }The UUID class is part of the java.util package library.