Cycle and operator

Operator:

Classification operator:
1, the assignment operator =
2, arithmetic operators + - * /% (die) + -
3 + compound operator = - = = * /% = =
4, relational operators>> = <<= ==! =
5, logical operators && ||!
6, Bitwise operators & | ~ ^ << >>
? 7, ternary operator:
assignment operator = function is to value the right of the equal sign, assigned to the variable on the left. Left must be variable.
% Used to find the remainder. Seeking remainder of the time, consistent with the dividend remainder symbol.
Note: Integer integer division, rounding the result (erase fractional part) division, the divisor is not 0
relational operators must be the result of a Boolean calculation
++ variable in front, by a first, and then use a variable
++ in after the variable, the first variable is used, in increasing 1
&& represents logical aND, and used to connect two expressions.
&& expression on both sides are true, the result will be true. As long as there is an expression is false, the result is false.
Note: Once && preceding expression was found to be false, and no longer to calculate the expression behind this phenomenon is called short circuit.
It represents a logical OR or ||.
|| left or right to a true result is true. Only when two persons are false, it is false.
! Logical NOT. Effect is negated. ! Right is an expression.
If the expression value is true, the entire expression is false

cycle:

There are three ways to achieve the cycle in the java: for while do ... while we call the cycle is repeated a number of times a piece of code execution depends on how many times our cycling conditions
for loop:
for loop syntax: for (expression 1; expression 2; expression 3) {statement (loop)} expression 1 cycle initial condition commonly referred to expression 2 cycle conditions referred to
the condition is true, loop body is executed, the condition is false, the loop ends expression 3-stop increments called cycle
continue the end of this cycle, the next cycle into the
break straight out of the loop
while loop:
in addition to the for loop cycle can be achieved, while also cycle
for the best use of recycling scene, know the number of cycles of the
while loop optimal usage scenarios, I do not know the number of cycles, but know cycling conditions
function for achievable, while able to achieve the
syntax of the while loop: while (loop condition) {statements}

do ... while loop:
do ... while loop can achieve
functions similar while
only difference with the while loop is executed at least once loop
ie: while the first determination condition is, whether the loop look
do ... while the first iteration of the loop, Analyzing conditions then
do ... syntax is the loop do {} while (loop condition);

Summary:
Development: Know when to use a for loop cycles
do not know the number of cycles but know cycling conditions, using a while loop
do not know the number of cycles, cycling know the conditions required to perform at least once in use do while loop
using the development of several cycles frequency:
for most
followed while (only if the number of cycles does not know when it is used)
almost do not do while

switch case:

switch branch structure
a branched structure: ... Case switch and its function if else if else if else the same syntax as follows: switch (constant expression) {Case
constant 1: 1 {statement BREAK; (out)} case constant 2: {Statement 2 break; (out)} case constant n: {statement n break; (out)
} default: {statement m break; (out)}}
Switch constant expression thereof may be byte, short, int, long, char, String type

Guess you like

Origin blog.csdn.net/csdn_hmt/article/details/88601461