Java Operators
Java Operators
Operators perform operations on operands like variables or values.
In Java, there are five types of operators based on the type of operations they perform. They are
Arithmetic Operators
Assignment Operators
Comparison Operators
Logical Operators
Bitwise Operators
Arithmetic Operators
Java Arithmetic Operators perform mathematical arithmetic operations and return the result. Following are the
arithmetic operators supported in Java.
Operator Name Description
+ Addition Returns the sum of two operands.
– Subtraction Returns the difference of right operand from left operand.
* Multiplication Returns the product of left and right operand.
/ Division Returns the division of left operand with right operand.
% Modulus Division Returns the reminder when left operand is divided by right operand.
++ Increment Increments the operand by 1.
— Decrement Decrements the operand by 1
Addition
Java Program
public class OperatorExample {
public static void main(String[] args) {
int a = 8;
int b = 3;
int c = a + b;
[Link](c);
}
}
Output
More about Java Addition Operator.
Subtraction
Java Program
public class OperatorExample {
public static void main(String[] args) {
int a = 8;
int b = 3;
int c = a - b;
[Link](c);
}
}
Output
More about Java Subtraction Operator.
Multiplication
Java Program
public class OperatorExample {
public static void main(String[] args) {
int a = 8;
int b = 3;
int c = a * b;
[Link](c);
}
}
Output
More about Java Multiplication Operator.
Division
Java Program
public class OperatorExample {
public static void main(String[] args) {
int a = 8;
int b = 3;
int c = a / b;
[Link](c);
}
}
Output
More about Java Division Operator.
Modulus Division
Java Program
public class OperatorExample {
public static void main(String[] args) {
int a = 8;
int b = 3;
int c = a % b;
[Link](c);
}
}
Output
More about Java Modulus Operator.
Increment
Java Program
Java Program
public class OperatorExample {
public static void main(String[] args) {
int a = 8;
int c = ++a;
[Link](c);
}
}
Output
More about Java Increment Operator.
Decrement
Java Program
public class OperatorExample {
public static void main(String[] args) {
int a = 8;
int c = --a;
[Link](c);
}
}
Output
More about Java Decrement Operator.
Java Tutorial
✦ Java Tutorial
✦ Java Introduction
✦ Java Installation
✦ IDEs for Java Development
✦ Java HelloWorld Program
✦ Java Program Structure
✦ Java Datatypes
✦ Java Variable Types
✦ Java Access Modifiers
➩ Java Operators
✦ Java Decision Making
✦ Java Loops
✦ Java Array
✦ Java OOPs
✦ Java String
✦ Java Exception Handling
✦ Java File Operations
✦ Java Date & Time
✦ Java MySQL
✦ Java Random
✦ Java Math