Skip to main content

Command Palette

Search for a command to run...

Relational and Logical Operators

Conditional statements in Java

Updated
1 min read
Relational and Logical Operators

Conditional statements use relational and logical operators.

Now, What is the meaning of those operators.

Relational operators are used for comparing the two values or data while Logical operators are used for combining and checking multiple conditions.

Look at the Relational operator in the below image.

ratio.jpg

The below image will help you to understand the different logical operators

logical oper.jpg

So, how this logical operator works?

  1. When you use AND operator, both the statements must be true.
  2. When you use OR operator and if any one of the statements is true, then the entire statement will be true.

In other words,

  1. AND will be true if both the statement are true.
  2. OR will be false if both the statements are false.

You can look at the below true/false table for justification.

truefalse.png

Important note: All these operations will return boolean-type results.

More from this blog

Stack Mahadev's Blog

24 posts