It looks like you’re getting the hang of this! Let’s explore another set of useful operators available in Java known as relational operators.

Relational operators compare data types that have a defined ordering, like numbers (since numbers are either smaller or larger than other numbers).

Relational operators will always return a boolean value of true or false.

Here are a few relational operators:

  1. < : less than.
  2. <=: less than or equal to.
  3. >: greater than.
  4. >=: greater than or equal to.

A relational operator is placed between the two operands (the terms that you want to compare using the relational operator). The result of a relational operation is printed out in the following statement:

System.out.println(5 < 7);

The example above will print out true because the statement “5 is less than 7“ is true.



Use one of the relational operators above to compare any two integers.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?