Java – Arithmetic Operators

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

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:

Addition: 110
Subtraction: 90
Multiplication: 1000
Division: 10
Modulo: 0