Java Syntax World – Examples & Explanation of Top Java Operators


If you are a Java developer or learning to become one, then this article will be very helpful for you. In this article, we are supposed to cover the top java operators that are very useful for the developers in their daily life. Moreover, we are going to share the utilization of these java operators with the help of one functional example.

Operators in JavaScript are the unique symbols which carry out operations on operands. Such as ‘+’ is a symbol which performs the operation of addition. So, let’s just learn some of the cool Java operators;

Assignment operators

The assignment operators are used to assign the particular value to a variable. Such as;

int age;

age = 5;

Here the assignment operator assigned the value on its right variable to the left variable   In this example, 5 is assigned to the variable age with the help of a = operator. There are plenty of other assignment operators available. However, to keep the tutorial simple we will learn about them later and in this post, we will check out the example of the = operator only.

Practical use; Input

class AssignmentOperator


   public static void main(String[] args) {


       int number1, number2;


       // Assigning 5 to number1

       number1 = 5;



       // Assigning value of variable number2 to number1

       number2 = number1;







Arithmetic operators

As the name suggests, Arithmetic operators are used to perform the mathematical operations like addition, subtraction, etc., There are different operators are dedicated to each mathematical function such as addition (+), subtraction (-), multiplication (*), division (/), remainder (%).

Practical use; Input

class ArithmeticOperator {

   public static void main(String[] args) {


       double number1 = 12.5, number2 = 3.5, result;


       // Using addition operator

       result = number1 + number2;

       System.out.println(“number1 + number2 = ” + result);


       // Using subtraction operator

       result = number1 – number2;

       System.out.println(“number1 – number2 = ” + result);


       // Using multiplication operator

       result = number1 * number2;

       System.out.println(“number1 * number2 = ” + result);


       // Using division operator

       result = number1 / number2;

       System.out.println(“number1 / number2 = ” + result);


       // Using remainder operator

       result = number1 % number2;

       System.out.println(“number1 % number2 = ” + result);




number1 + number2 = 16.0

number1 – number2 = 9.0

number1 * number2 = 43.75

number1 / number2 = 3.5714285714285716

number1 % number2 = 2.0

Unary operator

Unary operators are those operators which only perform one operant operation. There are plenty of of different unary operators are available such as;

+ unary operator is not necessary to use since numbers are positive without using it
Unary operator inverts the sign of an expression
++ increment operator use to increments value by 1
‘—‘ decrement operator used to decrements value by 1
! Logical complement operator use to inverts the value of a Boolean

Practical use; Input

class UnaryOperator {

   public static void main(String[] args) {


       double number = 5.2, resultNumber;

       boolean flag = false;


       System.out.println(“+number = ” + +number);

       // number is equal to 5.2 here.


       System.out.println(“-number = ” + -number);

       // number is equal to 5.2 here.


       // ++number is equivalent to number = number + 1

       System.out.println(“number = ” + ++number);

       // number is equal to 6.2 here.


       // — number is equivalent to number = number – 1

       System.out.println(“number = ” + –number);

       // number is equal to 5.2 here.


       System.out.println(“!flag = ” + !flag);

       // flag is still false.





+number = 5.2

-number = -5.2

number = 6.2

number = 5.2

!flag = true

We have to cut short here, the rest java operators will be explained in the next article in the series.

About the author

Arpit Agarwal

I am a freelancer content writer, web developer and Video editor who loves to write technical stuff and on the other hand makes awesome videos as well. I like to make people happy with my writing and also try to make sure, you come back to read more.

Add comment

Leave a Reply

By Arpit Agarwal

Most common tags

%d bloggers like this: