Various operators: Arithmetic operators:: +,-,*,/,%,++,--
+ +: self-increment
--: self-reduction
When used alone, + + or--whether placed in front of the variable or behind it, the result is the same.
When participating in the operation:
If + + or--at the back of the variable, take the variable to participate in the operation, after the variable to do + + or--
If + + or--at the front of the variable, the first variable to do the + + or--, take the variable to participate in the operation
Basic assignment Operator: = Extended assignment Operator: +=,-=,*=,/=,%=
a+=10; equivalent to a = (data type of a) (A + 10);
Relational operators: ==,!=,>,>=,<,<= (the result of a relational operator isBoolean, which is either true or false ) Logical operator: a:&,|,^,! B: &&,| |
& Logic with: False if False
| Logical OR: TRUE if
^ Logical XOR: Same as false, different to true
The logical non: false is true, False if not true
What is the difference between a:&& and &?
A: The end result is the same.
The b:&& has a short circuit effect. The left side is false and the right side is not executed.
& whether the left is false or true, the right side will execute
What is the difference between b:| | and |?
A: The end result is the same
b:| | has a short circuit effect. True on the left, not on the right
| Whether the left is false or true, the right side will execute
Ternary operator: (relational expression)? Expression 1: Expression 2;
If the condition is true, the result of the operation is an expression of 1;
If the condition is false, the result of the operation is an expression of 2;
Example: int x=1,y=2,z;
z = (x>y)? x:y; Z is the largest number in X, y
Java Basics Essay 2