Home » Java programming language

Java UUID equals() Method with Example

UUID Class equals() method: Here, we are going to learn about the equals() method of UUID Class with its syntax and example.
Submitted by Preeti Jain, on February 21, 2020

UUID Class equals() method

  • equals() method is available in java.util package.
  • equals() method is used to check whether this object equals to the given object or not.
  • equals() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.
  • equals() method does not throw an exception at the time of checking the equality of two objects.


    public boolean equals(Object ob);


  • Object ob – represents the Object (ob) is to be compared with this object.

Return value:

The return type of the method is boolean, it returns true when this object is same as the given object (ob) otherwise it returns false.


// Java program to demonstrate the example 
// of boolean equals(Object ob) method of UUID 

import java.util.*;

public class EqualsOfUUID {
    public static void main(String[] args) {
        // Instantiate UUID    
        UUID uuid1 = UUID.fromString("46400000-8cc0-11bd-b43e-10d46e4ef14d");
        UUID uuid2 = UUID.fromString("56500000-8cd0-10bd-b65e-10d46e4ef14d");

        // By using equals() method is
        // to check equality of this object
        // with the given object
        boolean status = uuid1.equals(uuid2);
        System.out.println("uuid1.equals(uuid2): " + status);


uuid1.equals(uuid2): false


Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.