Table of contents
1.
Introduction
2.
Why Use Arithmetic Operators?
3.
Arithmetic Operators in Java
3.1.
Addition(+)
3.2.
Subtraction(-)
3.3.
Multiplication(*)
3.4.
Division(/)
3.5.
Modulus(%)
4.
Real-Life Use Cases of Arithmetic Operators in Java
4.1.
1. Calculating Discounts, Averages, Totals
4.2.
2. Basic Math Utilities in Java Programs
5.
Frequently Asked Questions
5.1.
What are the 4 operators in Java?
5.2.
What is the function of operators?
5.3.
What is an example of an operator?
6.
Conclusion
Last Updated: Jun 29, 2025
Easy

Arithmetic Operator in Java

Author Sanjana Yadav
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

A programmer often creates a program to execute some function. For example, we may simply add two integers in a program using the + symbol.
In this case, + is a symbol that performs an operation known as an addition. In Java, such symbols are referred to as operators.

Arithmetic Operator in Java

An expression in Java consists of two parts: operand and operator. Operands are the variables or constants that operators act on.
In Java, an operator is a symbol or term instructing the compiler to do certain mathematical or logical operations.

Also see, Duck Number in Java and Hashcode Method in Java.

Why Use Arithmetic Operators?

Arithmetic operators in Java are essential for performing basic mathematical operations such as addition, subtraction, multiplication, division, and modulus. These operators form the foundation of any program involving data manipulation, numerical computation, or logical processing. Whether you're building a billing system or analyzing data, arithmetic operators are vital for implementing calculations and deriving results.

1. Performing Calculations in User Inputs

In billing or point-of-sale systems, arithmetic operators help calculate total cost, apply discounts, and add taxes. For example, adding product prices and multiplying by quantity gives the final bill amount.

int price = 100, quantity = 3;
int total = price * quantity;  // 300


2. Computing Formulas

Arithmetic operators are used to evaluate mathematical formulas such as area, interest, or averages. This is useful in educational apps, financial tools, or scientific applications.

double radius = 5;
double area = 3.14 * radius * radius;  // Circle area


3. Updating Variables

Operators like ++, --, and += help in updating counters or managing loops. This is especially useful in iterative logic such as counting, summing values, or pagination.

int counter = 0;
counter++;  // Increment by 1


4. Data Analysis or Processing in Business Applications

Arithmetic operators are used to summarize or transform data in tasks like calculating profit margins, revenue growth, or average ratings.

double revenue = 15000, cost = 10000;
double profit = revenue - cost;  // 5000

Arithmetic Operators in Java

These operators are mathematical operators that may be used to execute simple or complicated arithmetic operations on the operands, which are primitive data types. These operators are a collection of unary and binary operators that may be used on one or two operands. Let's have a look at the different arithmetic operators that Java has to offer.

Arithmetic Operators in Java

Addition(+)

This is a binary operator that adds two operands.

Syntax: 

num1 + num2

Example: 

import java.io.*;
public class Addition {
	public static void main(String[] args)
	{
		int num1 = 100, num2 = 200, sum = 0;
		// Displaying the two numbers 
		System.out.println("num1 = " + num1);
		System.out.println("num2 = " + num2);
		// adding the two numbers
		sum = num1 + num2;
		System.out.println("The sum = " + sum);
	}
}
You can also try this code with Online Java Compiler
Run Code

Output :

num1 = 100
num2 = 200
The sum = 300

Subtraction(-)

This is a binary operator that subtracts two operands.

Syntax: 

num1 -  num2

Example: 

import java.io.*;
public class Subtraction{
	public static void main(String[] args)
	{
		int num1 = 200, num2 = 100, diff = 0;

		// Displaying the two numbers 
		System.out.println("num1 = " + num1);
		System.out.println("num2 = " + num2);

		// subtracting the two numbers
		diff = num1 -  num2;
		System.out.println("The Difference = " + diff);
	}
}
You can also try this code with Online Java Compiler
Run Code

Output :

num1 = 200
num2 = 100
The Difference = 100


You can also read about Java Destructor and Swap Function in Java

Multiplication(*)

This is a binary operator that Multiplies two operands.

Syntax: 

num1 * num2

Example: 

import java.io.*;
public class Multiplication {
	public static void main(String[] args)
	{
		int num1 = 60, num2 = 40, res = 0;
		// Displaying the two numbers 
		System.out.println("num1 = " + num1);
		System.out.println("num2 = " + num2);
		// multiplying the two numbers
		res= num1 * num2;
		System.out.println("The Multuplication = " + res);
	}
}
You can also try this code with Online Java Compiler
Run Code

Output :

num1 = 60
num2 = 40
The Multiplication = 2400

Division(/)

This is a binary operator that divides the first operand (dividend) by the second operand (divisor), resulting in the quotient.

Syntax: 

num1 / num2

Example: 

import java.io.*;
public class Division {
	public static void main(String[] args)
	{
		int num1 = 200, num2 = 100, div = 0;
		// Displaying the two numbers 
		System.out.println("num1 = " + num1);
		System.out.println("num2 = " + num2);
		// dividing the two numbers
		div= num1 / num2;
		System.out.println("The Division = " + div);
	}
}
You can also try this code with Online Java Compiler
Run Code

Output :

num1 = 200
num2 = 100
The Division = 2

Modulus(%)

This is a binary operator that returns the remainder after dividing the first operand (dividend) by the second operand (divisor).

Syntax: 

num1 % num2

Example: 

import java.io.*;
public class Modulus{
	public static void main(String[] args)
	{
		int num1 = 3, num2 = 2, mod = 0;
		// Displaying the two numbers 
		System.out.println("num1 = " + num1);
		System.out.println("num2 = " + num2);
		// remaindering the two numbers
		mod = num1 % num2;
		System.out.println("The Remainder = " + mod);
	}
}
You can also try this code with Online Java Compiler
Run Code

Output :

num1 = 3
num2 = 2
The Remainder = 1

 

Compile it on online java editor.

Also check out Addition of Two Numbers in Java here.

Real-Life Use Cases of Arithmetic Operators in Java

Arithmetic operators are more than just basic math tools — they power everyday features in real-world Java applications. From billing systems to utility calculators, developers use these operators to build logic that users rely on daily. Let’s explore two practical use case types that beginners can easily relate to.

1. Calculating Discounts, Averages, Totals

In e-commerce platforms and billing systems, arithmetic operators help calculate prices, apply discounts, and average values like grades or ratings.

Example 1: Calculating Discount

double price = 500;
double discount = 10; // in percent
double finalPrice = price - (price * discount / 100);
System.out.println("Final Price: " + finalPrice);  // Output: 450.0
You can also try this code with Online Java Compiler
Run Code


Example 2: Calculating Average Marks

int m1 = 85, m2 = 90, m3 = 88;
double average = (m1 + m2 + m3) / 3.0;
System.out.println("Average Marks: " + average);
You can also try this code with Online Java Compiler
Run Code


Example 3: Total Price for Multiple Items

int itemPrice = 200, quantity = 4;
int total = itemPrice * quantity;
System.out.println("Total Bill: " + total);
You can also try this code with Online Java Compiler
Run Code

2. Basic Math Utilities in Java Programs

Developers often build utility functions using arithmetic operators for tasks like temperature or currency conversion, making apps more useful and interactive.

Example 1: Celsius to Fahrenheit

double celsius = 25;
double fahrenheit = (celsius * 9/5) + 32;
System.out.println("Fahrenheit: " + fahrenheit);
You can also try this code with Online Java Compiler
Run Code


Example 2: Currency Conversion

double usd = 100;
double inrRate = 83.2;
double inr = usd * inrRate;
System.out.println("INR: " + inr);
You can also try this code with Online Java Compiler
Run Code


Example 3: Area of a Rectangle

int length = 5, width = 4;
int area = length * width;
System.out.println("Area: " + area);
You can also try this code with Online Java Compiler
Run Code

Frequently Asked Questions

What are the 4 operators in Java?

Java arithmetic operators are used to accomplish operations such as addition, subtraction, multiplication, and division.

What is the function of operators?

An operator is a tool that is used to change individual data elements and deliver a result. These things are referred to as operands or arguments. Special characters or keywords are used to represent operators. 

What is an example of an operator?

An operator is defined as someone who controls a machine or the management or owner of a firm. A telephone switchboard operator is one example of an operator. An operator is someone who controls a crane at a loading dock, for example.

Conclusion

In this article we have extensively discussed arithmatic operators topics and their implementation in Java.With the help of examples of each, we saw addition, subtraction, multiplication, division and modulus operators in detail.

Check out the java interview questions to get hands-on experience with frequently asked interview questions and land your dream job.

To learn more about Micro Operations, refer to Arithmetic Micro Operations.

We hope that this blog has helped you enhance your knowledge regarding Aithmetic Operators in Java and if you would like to learn more, check out our articles on core java programming .

Live masterclass