# Arithmetic Operators in Java | Arithmetic Operations in Java

In this article, You will learn “Arithmetic Operators in Java|Arithmetic Operations in Java”. We can do basic mathematical operations using system languages along with arithmetic operators such that Java, JavaScript, and etc… Let’s start the article.

I hope you have already knowledge about arithmetic operations and operators but I’ll describe below once again for the remainder purposes.

2. Subtraction,
3. Multiplication,
4. Division,
5. Modulus,
6. Increament,
7. Decrement.

## Arithmetic Operators in Java|Arithmetic Operations in Java

Below, We can see the basic example program to execute a task here.

``````public class ArithmeticDemo {
public static void main(String[] args) {

//a few numbers
int i = 20;
int j = 30;
double x = 25.25;
double y = 50.50;
System.out.println("Variable values...");
System.out.println("    i = " + i);
System.out.println("    j = " + j);
System.out.println("    x = " + x);
System.out.println("    y = " + y);

System.out.println("    i + j = " + (i + j));
System.out.println("    x + y = " + (x + y));

//subtracting numbers
System.out.println("Subtracting...");
System.out.println("    i - j = " + (i - j));
System.out.println("    x - y = " + (x - y));

//multiplying numbers
System.out.println("Multiplying...");
System.out.println("    i * j = " + (i * j));
System.out.println("    x * y = " + (x * y));

//dividing numbers
System.out.println("Dividing...");
System.out.println("    i / j = " + (i / j));
System.out.println("    x / y = " + (x / y));

//computing the remainder resulting from dividing numbers
System.out.println("Computing the remainder...");
System.out.println("    i % j = " + (i % j));
System.out.println("    x % y = " + (x % y));

//mixing types
System.out.println("Mixing types...");
System.out.println("    j + y = " + (j + y));
System.out.println("    i * x = " + (i * x));

//increment operator
System.out.println("increment operator...");
System.out.println("    i + j = " + (++i + j));
System.out.println("    x + y = " + (++x + y));

//decrement operator
System.out.println("decrement operator...");
System.out.println("    i + j = " + (--i + j));
System.out.println("    x + y = " + (--x + y));
}
}``````

## Execution of Program

Initially, We have to declare the two sets of respective variables to store the input data. After that, We will mention the related operators with variables for the related operations inside the system.out.printIn() function directly.

Later, The public static void main() function will help to compile the program. Finally, The two sets of results will display on the output screen directly after executing this program.

`Read Also : Factorial Program in Java`

## Note

You can also do Arithmetic Operators in JavaScript | Arithmetic Operations in JavaScript. If you want to know then please refer to it.

## Output of Arithmetic Operators in Java|Arithmetic Operations in Java

Below, You will see the reference output of Arithmetic Operators in Java|Arithmetic Operations in Java.

``````Variable values...
i = 20
j = 30
x = 25.25
y = 50.5
i + j = 50
x + y = 75.75
Subtracting...
i - j = -10
x - y = -25.25
Multiplying...
i * j = 600
x * y = 1275.125
Dividing...
i / j = 0
x / y = 0.5
Computing the remainder...
i % j = 20
x % y = 25.25
Mixing types...
j + y = 80.5
i * x = 505.0
increment operator...
i + j = 51
x + y = 76.75
decrement operator...
i + j = 50
x + y = 75.75``````

## Final Words

I hope this article helps you to learn Arithmetic Operators in Java|Arithmetic Operations in Java. If you like this content then share it with other program learners. Do visit our website “Codingdiksha” and gain your knowledge with us. If you have any comments about this program then share them with us.

Share on:

Hi, I'm Manoj working as a part-time blogger in Coding Diksha. Here, I post about programming to help developers.