Java Boolean compare() methodLast Updated : 17 Mar 2025 The compare() method of Java Boolean class compares the two Boolean values (x and y) and returns an integer value based on the result of this method. Syntax:Parameters:Here, x(first boolean) and y( second boolean) are two boolean parameters passed which are compared. Return Value:This method returns an integer value.
Example 1ExampleCompile and RunOutput: b1 value is true Example 2Output: Enter two no.s I no :89 II no :98 98 is greater Example 3Output: Enter your percentage: 74.9999 Sorry! Your percentage is lower than our requirement. Next TopicJava Boolean |
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India