Skip to main content

Assignment + Equality and Relational Operators

Welcome! This page will teach you about Equality and Relational Operators as well as the Assignment Operator.

What is an Operator?
Operators within Java are signs used to manipulate a variable. Depending on what type of Operator is in use will determine the outcome.

What is an Equality and Relational Operator?
Equality and Relational Operators are used to check if a variable is a value. You can use one of these operators to check if the value of a variable is the exact same as another value or if it is within a range of values (see example below).

What is an Assignment Operator?
Unlike Equality and Relational Operators, there is only one operator for the "Assignment Operators" category. The only sign used for assignment is a single equals sign.

All Operators List:
Here is a list of all possible Equality and Relational Operators as well as the single Assignment Operator...

Assignment Operator:

= set equal to

Equality and Relational Operators:

== equal to
!= not equal to
> greater than
>= greater than or equal to
< less than
<= less than or equal to

Here is an example of setting a new variable integer named "ch" equal to 5, then checking if its;
equal to 3, greater than 3 or less than 3.

  1. int ch = 3;
  2. if (ch == 3){
  3. System.out.println("Ch is 3!");
  4. }else if (ch > 3){
  5. System.out.println("Ch is greater than 3!");
  6. }else if (ch < 3){
  7. System.out.println("Ch is less than 3!");
  8. }


Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.


1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Add new comment

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.