
10 Types of Programming Languages Every Coder should Know
Learn about different types of programming languages and how they are implemented in the real world.

Java is a versatile programming language that is widely used. It provides a rich set of features that facilitate programming tasks. These features are arithmetic operators, which are fundamental to performing mathematical calculations in any Java application. This article explores the arithmetic operators in Java language, their usage and some practical examples that demonstrate their power.
It is the special symbols that perform mathematical operations on numeric values. They allow developers to manipulate numbers in various ways, making them fundamental to programming in Java. These operators allow developers to carry out fundamental calculations such as addition, subtraction, multiplication, division and modules. They are essential for any programming task that requires numerical computations.
Program
public class Main{
public static void main(String args[]){
int a = 20 ;
int b = 3 ;
System.out.println("Addition = "+(a+b));
System.out.println("Subtraction = "+(a-b));
System.out.println("Multiplication = "+(a*b));
System.out.println("Division = "+(a/b));
System.out.println("Module = "+(a%b));
}
}
Output
Addition = 23
Subtraction = 17
Multiplication = 60
Division = 6
Module = 2

POSTGRADUATE PROGRAM IN
Multi Cloud Architecture & DevOps
Master cloud architecture, DevOps practices, and automation to build scalable, resilient systems.
Also Read: Java Operators
Arithmetic operators involve the mathematical operations on the operands. It can perform various simple or advanced arithmetic operations on the primitive data types referred to as the operands. In Java language, Arithmetic operators can be defined into two categories. Binary Operators and Unary Operators.
| Operator Name | Category | Operator | Description |
| Addition Operator | Binary | + | Addition of two numbers |
| Subtractor Operator | Binary | – | Subtraction of two numbers |
| Multiplication Operator | Binary | * | Multiplication of two numbers |
| Division Operator | Binary | / | Division of two numbers |
| Modulus Operator | Binary | % | Return the remainder after dividing two numbers |
| Increment Operator | Unary | ++ | Increase the value by 1 |
| Decrement Operator | Unary | – | Decrease the value by 1 |
This operator is used to perform the addition of two operands. It is a binary-type operator.
Syntax
operand 1 + operand2
Example Program
public class Main{
public static void main(String args[]){
int a = 20 ;
int b = 3 ;
int c = a+b ;
System.out.println("The addition of 20 and 3 is = "+c);
}
}
Output
The addition of 20 and 3 is = 23
Also Read: Logical Operators in Java
This operator subtracts one operand value to another operand value. It is also a binary operator that can deal with numeric values.
Syntax
operand1 - operand2
Example Program
public class Main{
public static void main(String args[]){
int a = 20 ;
int b = 3 ;
int result = a- b ;
System.out.println("The subtraction of "+a+" and "+b+ " is "+result);
}
}
Output
The subtraction of 20 and 3 is 17
The Java multiplication operator of (*) is used to multiply two numbers in a program as upheld by several researchers. It works with several integral and floating point types: pos integer, integer, floating point and double for positive and negative numeric values.
Syntax
result = operand1 * operand2;
Example Program
public class Main{
public static void main(String args[]){
int a = 25 ;
int b = 5 ;
int result = a * b ;
System.out.println("The mulitpliation of "+a+" and "+b+ " is "+result);
}
}
Output
The multiplication of 25 and 5 is 125
Also Read: Relational Operators in Java
This is a binary operator that is used to divide the first operand(dividend) by the second operand (divisor) and give the quotient as a result.
Syntax
num1 / num2
Example of the Program
class Main{
public static void main(String args[]){
int num1 = 20, num2 = 30, div = 0 ;
System.out.println("num1 = "+num1);
System.out.println("num2 = "+num2);
div = num1 / num2 ;
System.out.println("Division = "+div);
}
}
Output
num1 = 20
num2 = 30
Division = 0
Also Read: Bitwise Operators in Java
The modulus operator % is used in a fashion to return the remainder of the division of one number by another. This operator becomes most helpful in several cases including identifying whether a particular number is odd or even, cyclic operations, or in time calculations.
Syntax
operand1 % operand2
Example Program
class Main{
public static void main(String args[]){
int num1 = 20 , num2 = 30 , result =0 ;
result = num1 % num2 ;
System.out.println("The modulo of "+num1+" and "+num2+ " is "+result);
}
}
Output
The modulo of 20 and 30 is 20
The increment operator(++) is a unary operator used to increase the value of a variable by one. This can be applied in two forms, pre-increment and post-increment.
Example of Program
class Main{
public static void main(String args[]){
int a = 5;
int preIncrementResult = ++a;
System.out.println("Pre-increment: " + preIncrementResult);
a = 5;
int postIncrementResult = a++;
System.out.println("Post-increment: " + postIncrementResult);
System.out.println("Value of an after post-increment: " + a);
}
}
Output
Pre-increment: 6
Post-increment: 5
Value of an after post-increment: 6
Also Read: Increment and Decrement Operators in C
The decrement operator (–) is a unary operator. It declares the value of a variable by one. It can be used in two forms, pre-decrement and post-decrement.
Example of Program
class Main{
public static void main(String args[]){
int a =5 ;
int dec = --a ;
System.out.println("Pre-Decrement "+dec);
a= 5 ;
int postDec = a-- ;
System.out.println("Post-Decrement "+postDec);
System.out.println("Value of an after post-dec "+a) ;
}
}
Output
Pre-Decrement 4
Post-Decrement 5
Value of an after post-dec 4
Also Read: Bitwise Operators in Java
Any programmer must want to fully exploit Java and learn the arithmetic operators in Java. These are basic arithmetic operators which construct the fundamentals of calculations in applications, from basic arithmetic to extensive algorithms. Appreciation of how addition, subtraction, multiplication, division and modulo operations can be used as is and operated on for more efficient source code as well as benefiting the problem-solving abilities. Java arithmetic operation’s solid graphs of these basic concepts will help your programming skills and prepare you to work with more complex concepts as well. This empowers the arithmetic operators and takes your Java programming experience to another level. Get hands-on experience in Java with the Certificate Program in Application Development offered by Hero Vired.
Updated on October 24, 2024

Learn about different types of programming languages and how they are implemented in the real world.

Explore 10 front-end development, including key languages, its advantages and disadvantages, and how it shapes user experience in web design and functionality.