Java Data Type Tutorial - Java UUID.equals(Object obj)








Syntax

UUID.equals(Object obj) has the following syntax.

public boolean equals(Object obj)

Example

In the following code shows how to use UUID.equals(Object obj) method.

//from   w  w w.  j  a v a 2s. c om

import java.util.UUID;

public class Main {
   public static void main(String[] args) {
      // creating two UUIDs      
      UUID u1 = UUID.randomUUID();
      UUID u2 = UUID.randomUUID();
        
      // checking equality
      System.out.println("Is two UUIDs equal: "+u1.equals(u2));    
   }    
}

The code above generates the following result.