Java supports a rich set of operators, such as =, +, -, * and /. Operators are used in program to manipulate data and variables.
They usually form a part of mathematical or logical expression.
Java operators can be classified into a number of related categories as below:
- Arithmetic Operators
- Relational Operators
- Logical Operators
- Assignment Operators
- Increment and Decrement Operators
- Conditional Operators
- Bitwise Operators
- Special Operators
Arithmetic operator
Java provides all basic arithmetic operators.
These can be operated in a build-in numeric data type of java.
We cannot use this operator in Boolean types. List of arithmetic operators are as follows:
| Operators |
Meaning |
| + |
Addition and unary plus |
| - |
Subtraction and unary minus |
| * |
Multiplication |
| / |
Division |
| % |
Modulo division |
Relational Operators
We often compare two quantities, and depending on their relation, take certain decision.
We have already used the symbol ‘<’, meaning ‘less than’. An expression such as
a < b or x < 20
Containing a relational operator is termed as a relational expression.
The value of a relational expression is either true or false. For example if x = 10, then
x < 20 is true
20 < x is false
Java supports six relational operators in all. These operators and their meaning are given below:
| Operators |
Meaning |
| < |
is less than |
| <= |
is less than or equal to |
| > |
is greater than |
| >= |
s greater than or equal to |
| = = |
is equal to |
| != |
is not equal to |
Logical operators
In addition to relational operator, Java has three logical operators, which are given below: