Logical Expressions

In this lesson, an explanation of the use of logical expressions in Java programs is provided.

Introduction

Logical expressions are also known as Boolean expressions. It will always evaluate to a value of either true or false. Therefore, they will be represented by the data type boolean. While they may seem similar to mathematical operators, the difference lies in how they are used with comparative or boolean operators. Let’s look at both types of operators in detail.

Comparative operators

Java has several operators that can be used to compare value. Comparison implies knowing which value is greater than the other, or equal to it, and so on. The table below shows the entire list of operators available in Java.

Symbols Comparative operators
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to
== Equal to
!= Not equal to

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy