Java - Basic Operators
Categories: Java 8(JDK1.8)
Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups −
1. Arithmetic Operators
2. Relational Operators
3. Bitwise Operators
4. Logical Operators
5. Assignment Operators
6. Misc Operators
The Arithmetic Operators
Arithmetic operators are used in mathematical expressions in the same way that they are used in algebra. The following table lists the arithmetic operators −
Operator -Description -Example
+ (Addition)Adds values on either side of the operator.A + B will give 30
- (Subtraction)Subtracts right-hand operand from left-hand operand.A - B will give -10
* (Multiplication)Multiplies values on either side of the operator.A * B will give 200
/ (Division)Divides left-hand operand by right-hand operand.B / A will give 2
% (Modulus)Divides left-hand operand by right-hand operand and returns remainder.B % A will give 0
++ (Increment)Increases the value of operand by 1.B++ gives 21
-- (Decrement)Decreases the value of operand by 1.B-- gives 19