Operators are used in java along with the variables to achieve arithmetic, logical, conditional & relational functionalities. There are different types of operators available as below.
Types of Operators:
- Assignment Operator
- Arithmetic Operators
- Relational Operators
- Conditional Operators
- Unary Operators
- Type Comparison Operator
- Bitwise Operators
- Equality Operator
(=) It is used to assign any value to a variable.
int a = 2;
|!=||Not equal to|
|>=||Greater than or equal to|
|<=||Less than or equal to|
|?:||Ternary (shorthand for if-then-else statement)|
|+||Unary plus operator; indicates positive value (numbers are positive without this, however)|
|–||Unary minus operator; negates an expression|
|++||Increment operator; increments a value by 1|
|—||Decrement operator; decrements a value by 1|
|!||Logical complement operator; inverts the value of a boolean|
|~||Unary bitwise complement|
|<<||Signed left shift|
|>>||Signed right shift|
|>>>||Unsigned right shift|
|^||Bitwise exclusive OR|
||||Bitwise inclusive OR|
Type Comparison Operator:
instanceof – Checks whether the object is of specific type and returns a boolean.
== Checks whether the value of two variables are equal.