+ 4
Operators are used to initiate some sort arithmetic or logic operation on the given data. List of the commonly used operators is given below
a) Type of Operation.
- Precedence Operator: ()
- Arithmetic Operators: /, *, +, -, %
- Relational Operators: ==, !=, >, <, >=, <=
- Assigment Operator: =
- Logical Operators: && (and), || (or), !(not)
- Increment Operator: ++ (works only on integer type of variable). Unit increment
- Decrement Operator: -- (works only on integer type of variable)
- Composite Operators: +=, -=, *=, /=, %=
a = a + 2 => a += 2
- Conditional Operator: (boolean-expression)?expression2:expression3;
b) No of Operands.
- Uniary Operator: That works on single expression/value/variable
++, --, !
- Binary Operator: That requires atleast two operands
- Tenary Operator: That works on three operands
(boolean-expression)?expression2:expression3;
boolean-expression returns either true or false.
expression2-It will be processed if boolean-expression returns true
expression3-It will be processed if boolean-expression returns false
For more explanatory details please visit
http://www.javatpoint.com/operators-in-java