Classification operator

Arithmetic operators Ø

 

Arithmetic Operators

+

addition

-

Subtraction

*

multiplication

/

division

%

Remainder

++

Increment

--

Decrement

Ø assignment operator

Assignment Operators

=

Equal sign

+=

Plus equal

-=

Less equal

*=

Take equal

/=

In addition to equal

%=

Is equal modulo

Ø comparison operators

Comparison Operators

==

equal

more than the

Less than

>=

greater or equal to

<=

Less than or equal

!=

not equal to

Ø logical operators 

&& Logical AND and

In case of false is false, only the two sides at the same time is true, it is true

||   logical OR or

In case of true is true, only the two sides at the same time is false, it is false

! Non-inverted logic 

false false true variable becomes true

 

note

1. The two sides must be a logical operator of type boolean values, or the result of the boolean type expression

2. The result is a boolean logical expression data

Note that logical operators short problem:

Logic: If the left is false, then the right side of logic and arithmetic operators would not

Or logic: If the left side is true, then the right side of the logic or arithmetic operators would not

 

Ø  ternary operator

format:

Data type Boolean type variable name = expression? Results 1: 2 results;

 

Ternary operator calculated:

- boolean expression evaluates true, the overall result of the ternary operator as a result, assigned to the variable.

- boolean type expression result is false, the ternary operator as a result the overall result 2, assigned to the variable.

 

 

Operator precedence

Increment decrement operator> Arithmetic Operators> Comparison Operators> Logical Operators> Ternary Operator> Assignment operators

 

Guess you like

Origin www.cnblogs.com/libinhong/p/10988486.html
Recommended