The equals() method of Java Boolean class returns a Boolean value true if the specified argument is not null and is same as this object, else it returns false.

Syntax

public boolean equals(Object obj)

Parameters

The parameter ‘obj’ represents the Boolean object to compare with.

Return Value

This method returns a Boolean value which are as follows:

  • It returns Boolean value true, this object represents the same value
  • It returns Boolean value false, if this Boolean object represents different value.

Example 1

Output:

Example 2

Output:

Example 3

Output:

Pin It on Pinterest

Share This