75
Java Boolean equals() method
The equals() method of Java Boolean class returns a Boolean value. It returns true if the argument is not null and is a Boolean object that represents the same Boolean value as this object, else it returns false.
Syntax:
Parameters:
Obj – The object to compare with
Return Value:
This method returns a Boolean value,
- It returns true, if the Boolean objects represent the same value.
- It returns false, if the Boolean objects represent different value.
Example 1
Output:
equals() method returns false
Example 2
Output:
Enter your percentage. 60 Sorry! You have failed. You needed 4.0 more marks to pass. Try again next year.
Example 3
Output:
Enter two number. 78 0 Divide = 78/0 Division is not possible.
Next TopicJava Boolean