Java Operations · Lesson 3/10
30%
⏱ 10–15 min

Understanding Java Comparison Operators: Equal, Greater, Less and More

The result of executing comparison operators is a boolean value. Most often, comparison operators are used in expressions that control the if statement and various loop operators.

It is allowed to compare values of any type using the == and != operators.

Comparison using ordering operations is allowed only for numeric data types.

For example:

int a = 4;
int b = 1;
boolean c = a < b;

The following table contains all existing Java comparison operators:

Comparison Operators
Operator Description
== Equal to
!= Not equal to
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to

Java Core

1. Java Introduction
2. Run Your First Java App
3. Java Syntax
4. Java Operations
5. Operators
6. Arrays
7. Sorting Algorithms
8. Git & GitHub
9. OOP Basics
10. Lambda Expressions
11. Stream API
12. Inner Classes and Exceptions
‹ Previous lesson Next lesson ›