How to Java programming- Java operators.

Java operators are symbols that are used to perform operations. There are many types of operators in java such as unary operator, arithmetic operator, a relational operator, shift operator, bitwise operator, ternary operator and assignment operator.

1.Unary operator.

++ (Increment) Increases the value of operand by 1.
— (Decrement) Decreases the value of operand by 1.

3.Relational Operators.

== (equal to) Checks if the values of two operands are equal or not, if yes then condition becomes true.
!= (not equal to) Checks if the values of two operands are equal or not, if values are not equal then condition becomes true.
> (greater than) Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true.
< (less than) Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true.
>= (greater than or equal to) Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true.
<= (less than or equal to) Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true.

4.Shift operators.

<< (left shift) Binary Left Shift Operator. The left operands value is moved left by the number of bits specified by the right operand.
>> (right shift) Binary Right Shift Operator. The left operands value is moved right by the number of bits specified by the right operand.
>>> (zero fill right shift) Shift right zero fill operator. The left operands value is moved right by the number of bits specified by the right operand and shifted values are filled up with zeros.

5.Bitwise operators.

& (bitwise and) Binary AND Operator copies a bit to the result if it exists in both operands.
| (bitwise or) Binary OR Operator copies a bit if it exists in either operand.
^ (bitwise XOR) Binary XOR Operator copies the bit if it is set in one operand but not both.
~ (bitwise compliment) Binary One’s Complement Operator is unary and has the effect of ‘flipping’ bits.
&& (logical and) Called Logical AND operator. If both the operands are non-zero, then the condition becomes true.
|| (logical or) Called Logical OR Operator. If any of the two operands are non-zero, then the condition becomes true.
! (logical not) Called Logical NOT Operator. Use to reverses the logical state of its operand.

6.Ternary operators.

? : (Conditional) This operator consists of three operands and is used to evaluate Boolean expressions. The goal of the operator is to decide, which value should be assigned to the variable.

7.Assignment operators.

= (Simple assignment operator). Assigns values from right side operands to left side operand.
+= (Add AND assignment operator). It adds right operand to the left operand and assigns the result to left operand.
-= (Subtract AND assignment operator). It subtracts right operand from the left operand and assigns the result to left operand.
*= (Multiply AND assignment operator.) It multiplies right operand with the left operand and assigns the result to left operand.
/= (Divide AND assignment operator.) It divides left operand with the right operand and assign the result to left operand.
%= (Modulus AND assignment operator.) It takes modulus using two operands and assigns the result to left operand.
<<= (Left shift AND assignment operator.)
>>= (Bitwise AND assignment operator.)
&= (Right shift AND assignment operator.)
^= (bitwise exclusive OR and assignment operator.)
|= (bitwise inclusive OR and assignment operator.)

Anwar Yakkiparamban is the founder of Lauyou Learning. Prior to Lauyou learning, Anwar worked at ARD Engineering & Development, Qatar. He holds bachelor degree in Electronics and Communication Engineering from Govt. Engineering College Idukki.