In Java programming, we will always need math equations. And that’s why we must understand Operators in Java and their operands and expression. Continue reading this article, and you will be able to understand these three terms completely.
Before we go in detail, let’s have a glance at the following equation. Let’s say you are going to find the area of a rectangle. Therefore, the equation is as followed;
area = x * y
Here, in this equation, the total “area = x * y” is the expression. The multiple signs are the operator. At last, area, x, y are the operands.
Try the Java code below:
package main; import java.util.Scanner; public class First{ public static void main( String args[] ) { double area; System.out.printf("Please enter the size of any side: "); Scanner input = new Scanner(System.in); int x = input.nextInt(); System.out.printf("Please enter the size of the other side: "); int y = input.nextInt(); area = x * y; System.out.printf("The area of your rectange is %f%n", area ); } }
Output:

Operators in Java
Java operators are the foundation between the variables and values. Hence, in the java program, we can observe many examples. Among them, Operators in Java program has eight types in common.
- Unitary operators
- Relational Operators
- Shift Operators
- Bitwise Operators
- Assignment Operators
- Arithmetic Operators
- Ternary Operators
- Logical Operators
We will briefly describe all these Operator types in the Java program in the later lessons. Till then, let’s have a summary of them.
Types of Operators | Category | Priority |
Unary | Prefix | ++expr –expr +expr -expr ~ ! |
Post-fix | expr++, expr— | |
Relational Operators | Equality | == != |
comparison | < > <= >= instance of | |
Shift Operators | shifting | << >> >>> |
Bit-wise Operators | AND bit-wise | & |
XOR bit-wise | ^ | |
OR bit-wise | | | |
Assignment Operators | Assignment | = += -= *= /= %= &= ^= |= <<= >>= >>>= |
Arithmetic | Additive | + – |
Multiplicative | * / % | |
Ternary | ternary | ? : |
Logical Operators | AND Logical | && |
OR logical | || |
These are the most common Operators in java Program and we have demonstrated each of the operators in the later articles. We tried to illustrate the overall mechanism of the operators in the Java program with suitable examples. Stay with us and we promise you the best lessons for java lessons.