Java UUID.compareTo(UUID val)
Syntax
UUID.compareTo(UUID val) has the following syntax.
public int compareTo(UUID val)
Example
In the following code shows how to use UUID.compareTo(UUID val) method.
/* ww w .j a v a 2s. co m*/
import java.util.UUID;
public class Main {
public static void main(String[] args) {
// creating UUIDs
UUID u1 = UUID.randomUUID();
UUID u2 = UUID.randomUUID();
// comparing uuids
System.out.println("Comparing two UUIDs: "+u1.compareTo(u2));
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »