Java: Arithmetic Operators

Airthmetic Operators in Java

On this page we will discussing Airthmetic Operator in Java. It provides quite a variety of operators which come in handy to the programmer for the manipulation of variables.

1. Arithmetic Operators

Arithmetic operators are used in mathematical expressions in the same way that they are used in algebra, i.e, to perform the basic mathematical functions.

They are used in mathematical expressions in the same way that they are used in algebra, i.e, to perform the basic mathematical functions.

These operators perform the most simple calculations and are five in number as shown in the table.

OperatorFunctionality
+Addition
Subtraction
*Multiplication
/Division
%Modulus

Syntax with Example

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

// declare variables
int a = 26, b = 4;

// addition operator
System.out.println("a + b = " + (a + b));

// subtraction operator
System.out.println("a - b = " + (a - b));

// multiplication operator
System.out.println("a * b = " + (a * b));

// division operator
System.out.println("a / b = " + (a / b));

// modulo operator
System.out.println("a % b = " + (a % b));
}
}```

Output

```a + b = 30
a - b = 22
a * b = 104
a / b = 6
a % b = 2```

Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others