Java Tut – Operators

Arithmetic operator – Just like other languages
+,-,*,%,/++,– etc.

Relational Operators: ==,!=,>,<,>=,<= etc.
e.g:

Bitwise Operators: Java defines several bitwise operators,which can be pplied to the integer types,long,int,short,char, and byte

Bitwise operator works on bits and performs bit-by-bit operation.
Assume if a=60 and b=13; now in binary format they will be a s follows:
a=00111100
b=00001101
——————
a&b=00001100
a|b=00111101
Some operators:
& bitwise and, | bitwise inclusive or,^ bitwise exclusive XOR,~ bitwise compliment,<< left shift,>> right shift,>>> zero fill right shift
e.g:

Logical Operators:
&& logical AND,|| logical OR,! logical NOT
e.g:
assume boolean variable a holds true,b holds false.

Assignment Operator:

= simple assignment operator, += Ass and assignment operator c+=a is equivalent to c=c+a,-=,*=,/=,&=,%=,<<=,>>=,^=,|=

Conditional Operator/ternary operator:
syntax:
variable x= (expression)?value if true:value if false
e.g:

Instance of operator:
This  operator is used only for object reference variables.The operator checks whether the object is of particular type(class type or interface type).instance of operator is written as:

e.g:

output:

another example will still return true if the object being compared is the assignment compatible with the type on th right.

output: