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 CompositeName equals() method in Java with Examples The equals() method of a javax.naming.CompositeName class is used to compare this CompositeName with the specified object passed as a parameter and checks whether two objects are equal or not. If both objects are equal then the equals() method returns true else false. If passed obj is null or not a 2 min read Java File Class equals() Method with Examples The equals() method of Java File Class compares the pathname supplied in the argument to the pathname provided in the argument. If the parameter is not null and points to the same file or directory, this function returns true. The operating system determines if the two abstract pathnames are equival 2 min read CompoundName equals() method in Java with Examples The equals() method of a javax.naming.CompoundName class is used to compare this CompoundName with the specified object passed as a parameter and checks whether two objects are equal or not. If both objects are equal then the equals() method returns true else false. If passed obj is null or not a co 2 min read Charset equals() method in Java with Examples The equals() method is a built-in method of the java.nio.charset checks if a given object of charset is equal to another given object of the charset. Two charsets are considered equal if, and only if, they have the same canonical names. A charset is never equal to any other type of object. Syntax: p 2 min read ChoiceFormat equals() method in Java with Examples The equals() method of java.text.ChoiceFormat class is used to compare between two ChoiceFormat objects and give the Boolean value regarding the comparison.Syntax: public boolean equals(Object obj) Parameter: This method takes obj as parameter which is another ChoiceFormat object for comparison.Retu 2 min read Like