CoderSathi
  • Tutorial
    • Java Tutorial
    • Swing Tutorial
    • JDBC Tutorial
    • Java String Tutorial
    • Servlet and JSP Tutorial
  • Mongo DB
  • AWS
  • DevOps
  • Linux
  • Git
Home > Java > Arithmetic Operator in Java

Java Tutorial

  • Introduction
    • What is Java
    • History Of Java
    • Install Java
    • What is JVM
    • JDK vs JRE vs JVM
    • Java Bytecode
    • OOP vs POP
    • Compile and Run Java
  • Tokens, Expressions and Control Structures
    • Primitive data types
    • Integers
    • Floating Points
    • Characters
    • Booleans
    • User Defined Data Type
    • Declarations
    • Constants
    • Identifiers
    • Literals
    • Type Conversion and Casting
    • Variables
    • Default Variable Initialization
    • Command Line Arguments
    • Arrays of Primitive Types
    • Comment Syntax
    • Garbage Collection
    • Expressions
    • Operators
    • Arithmetic Operator
    • Bitwise and Shift Operator
    • Comparison or Relational Operators
    • Logical Operators
    • Assignment Operators
    • Ternary Operator
    • Increment and Decrement Operator
    • Control Statements
  • OOP Concepts
    • Class and Object
    • Create Class Instance
    • Method
    • Abstraction
    • Encapsulation
    • this keyword
    • Constructor
    • Pass by Value
    • Access Modifier/Control
    • Polymorphism
    • Method Overloading vs Method Overriding
    • Recursion
    • Nested and Inner Class
  • Inheritance and Packaging
    • Inheritance
    • extends Keyword
    • super Keyword
    • Object Class
    • Abstract class
    • Final Class
    • Java Package
    • Interface
  • Handling Error/ Exceptions
    • What is Exception
    • Exception Handling Keywords
    • Common Java Errors
    • User Defined Exception
    • Throwing and re-throwing Exception
    • finally Block
  • Strings
    • Java String Tutorial
  • Threads
    • Introduction
    • Create Thread
    • Thread Lifecycle
    • Thread Priority
    • Thread Synchronization
    • Inner Thread Communication
    • Thread Deadlock
  • IO and Streams
    • java.io Package
    • Files and Directories
    • Byte Stream
    • Character Stream
    • Console Input and Output
    • Serializable and Deserializable
  • Core Packages
    • java.lang Package
    • Math
    • Wrapper Classes
    • java.lang.Number
    • Double
    • Float
    • Integers
    • java.lang.Byte
    • java.lang.Short
    • java.lang.Long
    • java.lang.Character
    • java.lang.Boolean
    • java.util package
    • Vector Class
    • Stack Class
    • Dictionary Class
    • Hashtable
    • Enumeration or Enum
    • Generate Random Number
  • Holding Collection of Data
    • Arrays
    • Map
    • List
    • Set
    • Collection Interface
    • Collections Class
    • ArrayList
    • HashSet
    • TreeSet
    • Comparator
  • Java Bean
    • What is Java Bean
    • Advantages and Disadvantages of Java Bean
    • Java Beans API
    • Introspection
    • Java Bean Properties
    • Bound and Constrained Properties
    • BeanInfo Interface
    • Customizers
    • Java Beans Persistence
    • BeanDescriptor
  • Home

Arithmetic Operator in Java

Learn the concepts, implementation details, and practical steps with a clean developer-focused walkthrough.

Yuba Raj Kalathoki
By Yuba Raj Kalathoki
Last updated: July 1, 2026 · 3 min read · 0 Comments
Share: in X
Arithmetic Operator in Java

Arithmetic operator in Java let us perform basic math operations like addition, subtraction, multiplication, and division. The Arithmetic Operator in Java is essential for calculations in our code. Let’s dive in!

Table of Contents

  • List of arithmetic operator in Java
  • Addition operator
  • Subtraction operator
  • Multiplication operator
  • Division operator
    • Integer division
    • Floating-point division
  • Modulo operator
  • Operator Precedence
  • Conclusion

List of arithmetic operator in Java

When using the Arithmetic Operator in Java, one can easily manipulate numerical data. Let’s see the table that shows the detail of arithmetic operations:

OperatorMeaningExampleDescription
+Additiona+bAdds a and b
–Subtractiona-bSubtracts b from a
*Multiplicationa*bMultiplies a and b
/Divisiona/bDivides a by b
%Modulusa%bComputes the remainder of dividing a by b

Addition operator

The addition operator is denoted by + (plus) which is an arithmetic operator. It adds more than one number and returns the result. The following code adds variables a and b and assigns the result to variable c.

public class Addition {
	public static void main(String[] args) {
		int a = 10;
		int b = 5;
		int c;
		c = a + b;
		System.out.println("The sum of " + a + " and " + b + " is " + c);
	}
}

Output:

The sum of 10 and 5 is 15

Subtraction operator

The subtraction operator is denoted by – (minus) which is an arithmetic operator. It subtracts first number from the second number. The following code subtracts variable a from b and assigns subtracted result to variable c:

public class Subtraction {
	public static void main(String[] args) {
		int a = 10;
		int b = 5;
		int c;
		c = a - b;
		System.out.println("The subtract from " + a + " to " + b + " is " + c);
	}
}

Output:

The subtract from 10 to 5 is 5

Multiplication operator

The multiplication operator is denoted by * (asterisk) which is an arithmetic operator. This multiplies more than one number. The following code multiplies two variables a and b and assigns result to variable c.

public class Multiplication {
	public static void main(String[] args) {
		int a = 10;
		int b = 5;
		int c;
		c = a * b;
		System.out.println("The multiple of " + a + " and " + b + " is " + c);
	}
}

Output

The multiple of 10 to 5 is 5

Division operator

The division operator in Java is denoted by / (forward slash) which is an arithmetic operator. The following code divides variables a by b and assigns result to variable c.

Integer division

Truncates decimal results.

public class Division {
	public static void main(String[] args) {
		int a = 10;
		int b = 5;
		int c;
		c = a / b;
		System.out.println("The division of " + a + " by " + b + " is " + c);
	}
}

Output

The division of 10 by 5 is 2

Floating-point division

double preciseResult = 15.0 / 4; // Result: 3.75  

Modulo operator

The modulo operator in Java is denoted by % which is an arithmetic operator. The modulo operator produces the result as a reminder of the division of one number by another. The following code demonstrates the modulo operator dividing a variable a by b and assigns result to variable c.

public class Division {
	public static void main(String[] args) {
		int a = 10;
		int b = 5;
		int c;
		c = a / b;
		System.out.println("The reminder of division " + a + " by " + b + " is " + c);
	}
}

Output

The reminder of division 10 by 5 is 0

Operator Precedence

Arithmetic operators follow PEMDAS rules:

  1. Parentheses ()
  2. Multiplication *, Division /, Modulus %
  3. Addition +, Subtraction -

Example:

int result = 10 + 5 * 2; // 20 (5*2 evaluated first)  
int corrected = (10 + 5) * 2; // 30  

Conclusion

Arithmetic operators are the backbone of math in Java. By understanding these operators we can handle calculations confidently. Keeping our code simple and test edge cases!

Related Posts:

  • PEMDAS in Java: Order of Operations Explained with Examples
  • MySQL Commands for Developers
  • Control Statements in Java
  • What Is Java Swing? A Complete Guide to Java’s GUI Toolkit
  • What is Java? Exploring Its Key Features, Benefits,…
  • Expressions in Java
Tags:javalanguage-fundamentals
Was this article helpful?
← Previous ArticleOperators in Java
Next Article →Increment and Decrement Operator in Java

Leave a Comment Cancel reply

You must be logged in to post a comment.

Recent Posts

  • How to implement Passwordless Authentication in Spring Boot: A Step-by-Step Guide
  • How to Use AWS CloudFront Signed URLs in Spring Boot?
  • How to Fix SSH Agent Forwarding on macOS: The Ultimate Guide for Developers
  • How to Read AWS Secrets Manager in Spring Boot (Step-by-Step)
  • How to Fix “Public Key Retrieval is not allowed” MySQL JDBC Error
CoderSathi

Your go-to resource for Java, Spring Boot, Microservices, AWS, and modern development tutorials.

Linkedin

Quick Links

  • About
  • Contact

Popular Topics

  • Java
  • Spring Boot
  • AWS
  • DevOps
  • MongoDB
  • Linux
  • Git
  • How to
© 2026 CoderSathi. All rights reserved. Privacy Policy · Sitemap