Boolean equals() method in Java with examples Last Updated : 09 Oct, 2018 Comments Improve Suggest changes Like Article Like Report The equals() method of Boolean class is a built in method of Java which is used check equality of two Boolean object. Syntax: BooleanObject.equals(Object ob) Parameter: It take a parameter ob of type Object as input which is the instance to be compared. Return Type: The return type is boolean. It returns true if the specified Object 'ob' has same value as the 'BooleanObject', else it returns false. Below are programs to illustrate the equals() method of Boolean class: Program 1: JAVA // Java code to implement // equals() method of Boolean class class GeeksforGeeks { // Driver method public static void main(String[] args) { // Boolean object Boolean a = new Boolean(true); // Boolean object Boolean b = new Boolean(true); // compare method System.out.println(a + " comparing with " + b + " = " + a.equals(b)); } } Output: true comparing with true = true Program 2: JAVA // Java code to implement // equals() method of Java class class GeeksforGeeks { // Driver method public static void main(String[] args) { // Boolean object Boolean a = new Boolean(true); // Boolean object Boolean b = new Boolean(false); // compare method System.out.println(a + " comparing with " + b + " = " + a.equals(b)); } } Output: true comparing with false = false Program 3: JAVA // Java code to implement // equals() method of Java class class GeeksforGeeks { // Driver method public static void main(String[] args) { // Boolean object Boolean a = new Boolean(false); // Boolean object Boolean b = new Boolean(true); // compare method System.out.println(a + " comparing with " + b + " = " + a.equals(b)); } } Output: false comparing with true = false Comment More infoAdvertise with us Next Article Boolean equals() method in Java with examples K kundankumarjha Follow Improve Article Tags : Java Java - util package Java-Functions Java-Boolean Practice Tags : Java Similar Reads Byte equals() method in Java with examples The equals() method of Byte class is a built in method in Java which is used to compare the equality given Object with the instance of Byte invoking the equals() method. Syntax ByteObject.equals(Object a) Parameters: It takes an Object type object a as input which is to be compared with the instance 2 min read Double.equals() Method in Java with Examples The Double.equals() in Java is a built-in function from the java.lang.Double class. This method compares the content of two Double objects. The result is true if and only if the argument is not null and is a Double object that contains the same double value as this object. This method is useful for 3 min read BitSet equals() Method in Java with Examples The equals() method of Java BitSet class is used to check for equality between two bitsets. It verifies whether the elements of one set passed as a parameter is equal to the elements of this set or not. The method returns true if the bitsets match else false. Syntax: Bit_Set1.equals(Bit_Set2) Parame 2 min read Date equals() method in Java with Examples The equals() method of Java Date class checks if two Dates are equal, based on millisecond difference. Syntax: public boolean equals(Object obj) Parameters: The function accepts a single parameter obj which specifies the object to be compared with. Return Value: The function gives 2 return values sp 2 min read Boolean compare() method in Java with Examples The compare() method of Boolean class is a built in method in Java which is used to compare two boolean values. It is a static method, so it can be called without creating any object of the Boolean class i.e. directly using the class name. Syntax: Boolean.compare(boolean a, boolean b) Parameters: It 2 min read Like