# [Tutorial 4] : Operators in Java explained – Arithmetic and Relational

Okay so, In the previous post , I introduced about the different types of operators in Javaand also gave you a brief knowledge about the two main types of Operators used in Java that are – Arithmetic Operators and relational Operators.

Let us begin the tutorial for today with Arithmetic operators.

Let us begin the tutorial for today with Arithmetic operators.

## What are Arithmetic Operators in Java ?

Well , As we I already told you in the previous article that the operators used in Java to perform the basic addition , subtraction , multiplication , division and remainder operations are known as Arithmetic operators.

So , to summarise , Arithmetic operators are those which help you to perform the basic mathematical calculations in Java.

Now , I will give you the example of a Java program that is to be typed in BlueJ and this will make you clear about Arithmetic Operators.

So , to summarise , Arithmetic operators are those which help you to perform the basic mathematical calculations in Java.

Now , I will give you the example of a Java program that is to be typed in BlueJ and this will make you clear about Arithmetic Operators.

public class arithmetic_operators

{

public static void main()

{

int x = 25; //Value 25 assigned to variable x

int y = 7; //Value 7 assigned to variable ySystem.out.println(x+y);System.out.println(x-y);System.out.println(x*y);System.out.println(x/y);System.out.println(x%y);}}

**This program will produce the output as follows :-**

**32**

**18**

**175**

**3**

**4**

**Summarising Arithmetic operators –**To summarise all that we saw above , we can say that Arithmetic operators are used in doing calculations and there are five kinds of Arithmetic Operators namely Addition , Subtraction , Multiplication , Division , Modulus.

**ADDITION GIVES THE SUM OF NUMBERS**

SUBTRACTION GIVES THE DIFFERENCE

MULTIPLICATION GIVES THE PRODUCT

DIVISION GIVES QUOTIENT

MODULUS GIVES REMAINDER.

SUBTRACTION GIVES THE DIFFERENCE

MULTIPLICATION GIVES THE PRODUCT

DIVISION GIVES QUOTIENT

MODULUS GIVES REMAINDER.

**IMPORTANT –**You might be confused that “System.out.println” command is used to print something , so why is this program not printing the words as it is between the brackets. Well , It is because the words are printed only when they are enclosed between

**(“”)**

**NOTE**– You are advised to type this code in BlueJ and see the output.

Now, Let carry forward our discussion towards Relational Operators.

##
What** are Relational Operators in Java ?**

To be short and brief , We can quote that

**“Relational Operators in Java are the ones that are used to perform various comparisons between different kinds of operands.”**## What is an Operand –

Operand is a quantity on which an operation is done or on which an Operator is used.

Now , In order to make your concepts clearer , Here is an example of a program illustrating relational operators in Java.

public class relational_operators{public static void main(){int x = 25;int y = 7;System.out.println(x<y);System.out.println(x>y);System.out.println(x<=y);System.out.println(x>=y);System.out.println(x==y);System.out.println(x!=y);}}

**The output of this program is as follows :-**

**false**

**true**

**false**

**true**

**false**

**true**

So , We have seen that in the case of relational operators , the output is shown in the form of

**“TRUE” OR “FALSE”**Now I think you must be clear with the basic concept about Arithmetic and Relational Operators and you know how to use them.**You can comment down all your thoughts as well as queries and they will be resolved immediately.**
Hello Every One thanks For Visit My site You Can Suggest any Idea About site And Related Education Information Provide me Its Best Content For you am Include in this Site And feel free contact And email now I hope This site very help full you