I. Sequential structure
Sequential structure is the most basic process control of a program, there is no specific grammatical structure, followed by top-down execution.
II. selection structure (branching structure)
1, If-else statement
if (conditional expression) {/* Determines whether the conditional expression is true, and if true, executes the contents of the code block;
Executes a block of code, and executes a block of code, jumps out of the If-else statement, and is bound to execute one;
}else if (conditional code block) {/* If the execution statement has only one {} can be omitted.
Execute code block;
}
.........
else{
Execute code block;
}
2, switch statement
Switch (variable) {/* variable: char byte short int Sting enumeration;
Case value 1: * No break, will continue to execute;
The default statement indicates that when all cases do not match, the
Case value 2: * content;
break; * Default position can be swapped, but always the last one executed.
... * * Only constants are behind the case.
Default
Break
}
Egg
650) this.width=650; "title=" QQ picture 20170620195925.png "alt=" Wkiom1ljdrft6-a2aacjqphu7ba525.png "src=" https:// S5.51cto.com/wyfs02/m00/99/84/wkiom1ljdrft6-a2aacjqphu7ba525.png "/>
+ Keyboard input data
(1) Guide package: Import Java.util.Scanner;
(2) Create an object of the Scanner class: Scanner s = new Scanner (system.in);
Sysout Tips keyboard input what things;
(3) The object to invoke the secondary input: String st = S.next (); String
int i = S.nextint (); Integer
Three, cycle structure
1, for Loop statement
for (initialization condition; loop condition; iteration condition) {
Circulation body;
}//Until the loop condition is not satisfied, exit the loop.
Egg:for (int=1;i<=100;i++) {
System.out.print (i + "t");
} The traversal of natural numbers within//100;
Difference between 2, while loop/* for loop and while loop
initialization condition; * The initialization condition of the for loop can no longer be used in the loop;
while (loop condition) {*/While the initialization condition of the loop is also available for looping.
Circulation body;
iterative conditions;
}
3, do While loop/* Whlie loop and do While loop difference
The initialization condition; * Does while looping at least once;
do{* * While loop does not.
Circulation body;
iterative conditions;
}while (cyclic condition)
4, Infinite cycle
(1) for (;;) {}//break jumps out of the current loop;
(2) while (true) {}//continue jumps out of the secondary loop.
5, nested loop (equivalent to the inner loop as a whole loop of the outer loop body)
Egg
650) this.width=650; "title=" QQ picture 20170621173103.png "style=" Float:none; "src=" https://s5.51cto.com/wyfs02/M02/99/ 9f/wkiol1lkpdgwb7xqaabugwhdpdm572.png "alt=" Wkiol1lkpdgwb7xqaabugwhdpdm572.png "/>650) this.width=650;" Width= " 288 "height=" 352 "title=" QQ picture 20170621173143.png "style=" Width:288px;height:362px;float:none; "src=" https:// S1.51cto.com/wyfs02/m01/99/9f/wkiol1lkpdktbvxxaaacdbdmqxa488.png "alt=" Wkiol1lkpdktbvxxaaacdbdmqxa488.png "/>
Java Program Flow Control