Hi There , Now talk about Java Basic Operators. See the below Table for Operator Summary
Postfix operators |
[] . (parameters) 1++ 1-- |
Unary prefix operators |
++1, --1, +1, -1, ~ ! |
Unary prefix creation and cast |
new (type) |
Multiplicative |
* / % |
Additive |
+ - |
Shift |
<< >> >>> |
Relational |
< <= > >= |
Equality |
== != |
Bitwise/logical AND |
& |
Bitwise/logical XOR |
^ |
Bitwise/logical OR |
| |
Conditional AND |
&& |
Conditional OR |
|| |
Conditional |
?: |
Assignment |
= += -= *= /= %= <<= >>= >>>= &= ^= | |
Increment(++) and Decrement(--) Operators
Now we Test Postfix & prefix operators . 1++ ,++1
💀 Postfix operators . 1++ ,1--
Postfix increment operator has like this semantics.
Ex: i++ , 10++ , i--, 10--
i++ uses the current value of i as the value of the expression first, then adds 1 to i. i-- uses the current value of i as the value of the expression first, then subtracts 1 to i. It is equivalent to the following statements like this.
Simple Code Below.
💀 prefix operators . ++1 , --1
Prefix increment operator has like this semantics.
Ex: ++i , ++8 , --i , --8
Simple Code Below.
Arithmetic Operator 's. + - * / %
See This is Simple Code Below.
Relational & Equality Operator 's. <, <=, >, >= ,== , !=
Now we see How to use Relational Operator in code. Relational Operator Use How to match or what Relation in two variable or values . like below eg :
A Match B , A Bigger Than B , A Less Than B .
See This code :
Boolean Logical Operator 's.
Boolean logical operators include the unary operator ! (logical complement) .
The binary operators
& (logical AND),
| (logical inclusive OR),
^ (logical exclusive XOR,
~ ( logical complement).
Boolean logical operators can be applied
to Boolean operands, Returning a Boolean value.
How to use java Shift Operators: <<, >>, >>>
In the above example :
24 is = 32
25 is =64
26 is =128
See the below code :
The Conditional Operator : ?
condition ? expression_1 : expression_2
Condition is false output expression_2
boolean Ans = false;
int i = Ans ? 1 : 0; // 0
Condition is true output expression_1
boolean Ans = true;
int i = Ans ? 1 : 0; // 1
See the below code :
Tags:
Java