These are symbols which use to perform specific arithmetic or logical operations. Injava, we found many type of operators. We will discuss for each of them below.

1. Arithmetic Operators – in java, we found arithmetic operators like+(addition) –(subtraction) *(multiplication) /(divide) %(modulus)

Let’s understand through below examples

Let’s a make a code, which divides two values and displays remainder and quotient of them.

2. Logical Operators – In java, there are 3 types of logical operators

First discuss about, AND operator– if both input goes same, then output goes same. Let’s see first code

Let’s see another code using AND operator

Note – in this code, if block will not execute. Because first condition (a==10) satisfies but second condition (b==22) not satisfied.In the case of AND operator it checks both conditions is true.

** Nowlet’s implement above same code base for OR operator.

Let’s see first code

Let’s see another code using OR(||) operator

Note – in this code, if block will be execute. Because first condition (a==10) satisfies though second condition (b==22) not satisfied. In the case of OR operator it checks at-least one condition is true.

** Now let’s implement NOT operator.

3. Unary operator –

In java, in the case for unary operator we found increment and decrement cases.

Increment case: a++ ++a

Decrement case: a– –a

** for the increment cases, a++ and ++a output goes same

** for the decrement cases, a—and –a output goes same

Lets first go through with increment cases :

Let’s go through with decrement cases :

Assignment Operators

This operator helps to initializes values into variable. There are many assignment operators which plays their roles differently. Assignment operators like  = += *=  etc.

Let’s understand through below coding examples –

Let’s see some another coding examples

x += y   it’s mean x = x + y

Let’s see some another coding examples

x *= y   it’s mean   x = x * y

Let’s see some another coding examples

X %= Y

Means, X = X % Y

Let’s understand through below coding example

Relational Operators

In java like other programming languages, we found many relational operators <(greater than) <(less than)  >=(greater than equal)  <=(less than equal)  ==(checks both operands are equal or not)

Let’s see some coding examples

Let’s see another coding examples

Ternary Operator

In java, we can work with ternary operator.

Syntax – variable = expression 1 ? expression 2: expression 3

Remember – if ‘expression 1’ satisfies then ‘expression 2’ will get into ‘variable’. If ‘expression 1’ not satisfies then ‘expression 3’ will get into ‘variable’.

Let’s understand through below code example

Let’s understand other examples

Shift Operator

In java, we have basically three types of shift operators – signed left shift(<<) and signed right shift operators(>>) and unsigned right shift(>>>).

Left Shift Operator

Let’s take an example,

10<<2 means 10*(2*2) = 10*4 = 40

20<<3 means 20*(2*3) = 20*8 = 160

Let’s understand through below coding example

Right Shift Operator

10>>2 means 10/(2*2) = 10/4 = 2 (stores quotient)

20>>3 means 20/(2*3) = 20/8 = 2

Let’s understand through below coding example

Difference between >> and >>> operator

Both >> and >>> are used to shift the bits towards the right. The difference is that the >> preserve the sign bit while the operator >>> does not preserve the sign bit. To preserve the sign bit, you need to add 0 in the MSB.

Let’s understand below code example

In java, we found many type of characters. Let’s discuss about them

1. Newline Characters – it adds a new line. It represented using \n . but remember one thing, when we using println() method it generate a new line in it’s statement. For print() method use cases it can’t happened.

Let’s understand by this below code – we will see using newline character and without using newline character.

Tab Character – using this character, we can generate tab. Let’s understand through below example…