java control structure

if the structure

IF (condition) {
 // execute code 
} the else  IF (condition) {
 // execute code 
} the else {
 // execute code 
}

 

and if both conditions are true else if relevant part of the code executed, else the current-determining face is executed when false.

switch structure

Switch (variable) {
 Case constant 1:
 // execute code 
BREAK ;
 Case constant 2:
 // execute code 
BREAK ;
 default :
 // execute code 
}

When the variable and constant value of the same case, the code execution belongs, BREAK If not, proceed downward.

switch is no default, break out, the code execution.

while loop

the while (loop condition) {
 // execute code 
}

do ...... while loop

do {
 // execute code 
} the while (loop condition);

for loop

for (loop variable; loop condition; change) {
 // execute code 
}

Enhanced for loop

for (stated objects: Array) {
 // execute code 
}

The same type of object type and an array of declared

 

Guess you like

Origin www.cnblogs.com/blunFan/p/11599767.html