Arithmetic Operators
Arithmetic operators in Java are used to perform mathematical operations on numeric data types.
We can perform basic mathematical operations with numbers.
int a = 4;
int b = 5;
Addition (+)
Adds the two inputs.
System.out.println(a + b); // prints 9
Subtraction (-)
Subtracts the right operand/value from the left value.
System.out.println(a - b); // prints -1
Multiplication (*)
Multiplies the two inputs.
System.out.println(a * b); // prints 20
Division (/)
Use /
(forward slash) for division. It divides the left operand by the right operand.
Integer division truncated any fractional part.
System.out.println(a / b); // prints 20