Basic types of automatic conversion
Follow the rules: ranging from small to large
例:long i = 100 注& int==>long
例:double z = 3.9F 注& float==>double
Cast
Example: int i = (int) 100L Note & int ==> long type, need to add the left (int)
Logical Operators
example:
And: 1 + 2 & 2 + 1 = 3 // ture are arithmetic left and right
Or: 1 + 2 | 2 + 3 = about 3 // true operation are
And short-circuit: 1 + 2 && 2 + 1 = 3 // ture
Or short circuit: 1 + 2 || 2 + 3 = 3 // true
Non (inverted): 1 + 2! = 3 // flase
XOR: 1 + 2 ^ 3 + 5 = 3 // ture
Ternary operator
Variables must be returned
int w = 5 > 3?7:6
Swich Process Control
swich (variable):
case1:
case2:
// otherwise been encountered only stop penetration
break;
Always // no match for the run to this point
default;
While Loop
while (condition) {
Loop
Stepping statements}
Note: infinite loop if conditions are ture to
do while{
Loop
Stepping statement} while (condition)
Note: do while after the first cycle is determined
Always // no match for the run to this point