1. Arithmetic Operators:
They are used to perform basic arithmetic operations. They perform on primitive data types.
They are:
- * : Multiplication
Multiplies two values
Example:x * y;
- / : Division
Divides one value from another
Example:x / y;
- % : Modulo
Returns the division remainder
Example:x % y;
- + : Addition
Adds together two values
Example:x + y;
- – : Subtraction
Subtracts one value from another
Example:x - y;
Example of Arithmetic Operator
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | public class ArithmeticOperator { public static void main(String args[]) { int number1 = 100; int number2 = 10; System.out.println("Addition: " + (number1 + number2) ); System.out.println("Subtraction: " + (number1 - number2) ); System.out.println("Multiplication: " + (number1 * number2) ); System.out.println("Division: " + (number1 / number2) ); System.out.println("Modulo: " + (number1 % number2) ); } } |
Output:
1 2 3 4 5 | Addition: 110 Subtraction: 90 Multiplication: 1000 Division: 10 Modulo: 0 |