Mathematical operations are used everywhere whether to calculate a company's payroll or the employees' number. The structure of an operation is composed of operands and operators and usually The result is assigned to variables. the statement below is an example of an operation.
int a=1 + 2;
Java supports other operators for different purposes :
We'll see each one in the next sections .
Java supports using the following classical arithmetic operators
These operators are usually used to assign Mathematical operations results to variables .The most-used assignment operator is the equal operator "=", which simply assigns operations' result to variables.
Sometimes, You'll encounter Compound Assignment operators which always have the equal sign on the right side beside other operators +=, -=, *=, /=, %=, &=, ^=, !=, <<=,>>=, >>>=
This way of writing operators behaves as a shortcut that uses the previous value of the statement's variable as an operand in the whole operation.
Relational operators are used to evaluate a test case before entering a protected block of code
These operators are used to verify a set of tests either
Ternary operators are used to compact conditional blocks of code into one line. These conditional blocks must treat only two cases, for instance, this example
If the Test evaluates to true, the first case block is entered, otherwise, the second.
These kind of operators are involved with just one expression, they don't need more than one operand unlike arithmetic operators.
These operators are less commonly used, They perform bits' operations :