Home » »

# Arithmetic Operators in Java Programming

|| || 0

Arithmetic Operators in Java Programming Stechies

## Basic and Compound Arithmetic Operators in Java

This tutorial explains the various basic and compound arithmetic operators and Augmented/Compound assignment operator available in JAVA Programming Language.

### What is Arithmetic Operators

Arithmetic operators are the mathematical expression which is used in java same as they are used in Algebra.

Arithmetic operators in Java Program are used with the variables which are created in a program.

Note: Arithmetic operators can't be used with boolean variables.

### Types of Arithmetic Operators in JAVA

 Operator Meaning Example + Addition 3 + 4 - Subtraction 4 - 2 * Multiplication 3 * 2 / Division 8/4 % Modulus 5%2

There is also some Augmented/Compound assignment operator which are nothing but using the above Arithmetic Operators along with assignment operator, for example, +=, -=, *=, /=, %=.

### Java Program using Arithmetic operators

public static Arithmetic {

public static void main (String[] args) {

int num1, num2; //declaring variables//
num1 = 15; //assigning value//
num2 = 30;

System.out.println(num1 + num2); //Addition operators//
System.out.println(num1 - num2); //Subtraction operators//
System.out.println(num1 * num2); //Multiplication operators//
System.out.println(num1 / num2); //Division operator//
System.out.println(num1 % num2); //Modulus operator//

}

}

### Java Program using Augmented Assignment Operator

public static Arithmetic {

public static void main (String[] args) {

int num1, num2;
num1 = 15;
num2 = 30;

num1 += num2; //Augmented Assignment Operator//
System.out.println(num1);
}
}

Related Articles