title: To compare UUID, can I use == or have to use UUID.equals(UUID)?
body: <p>Just start using <code>java.util.UUID</code>. My question is if I have two UUID variables, say u1 and u2, and I would like to check if they are equal, can I safely use expression <code>u1 == u2</code> or have to write <code>u1.equals(u2)</code>? assuming both are not null. </p>
  
  <p>BTW, I am using its <code>randomUUID</code> method to create new UUID values, but I think this should not be matter. 
  I wonder as UUID is unique, each value could be a singleton, then it is safe to use <code>u1 == u2</code>.  </p>
  
  <pre><code>void method1(UUID u1, UUID u2) {
  
     // I know it is always safe to use equal method
     if (u1.equals(u2)){ 
       // do something
     }
  
     // is it safe to use  ==
     if (u1 == u2) {
       // do something
     }
  }
  </code></pre>