Select structure: If structure: structure:
if () {: //Function Statement }else if () { //Function Statement }else if () { //Function Statement }else{//Other case not established after execution /function statement }
Characteristics:
1.if structure Independent write-off, with no effect on each other in order to judge and execute sequentially
2. If chain structure, if is mutually exclusive, when one of them executes, the condition is judged successfully, the IF structure ends
Precautions:
If the struct is not written, it will only control whether the first sentence of the IF structure is executed
Switch structure: structure notation:
switch (value variable expression) {//value, must be a Java-defined type case value: function statement; Case value: function statement; break; Case value: function statement; break; ....... Case value: function statement; break; Default: function statement; break;}
Execution process:
According to the value of the parentheses after the switch, in the switch structure, determine whether the value followed by the case is matched with the value in parentheses, if matching, execute the function statement after the corresponding value of the box, the function statement is completed, a break is encountered, the selection structure ends, default: If there is no match after all case values are compared to the values passed in, the function statement following the default will be executed
Precautions:
1. Default can not be written
2. The order can be casually written: But it is recommended to follow the order
3. After matching the first case, execute the function statement, and before encountering the first break, all case invalidation
4. Generally written in the last condition, can not write break
5. Default: If written in front, it is best to write a break
Variable support type in switch ():
Java5 before: byte short char int
JAVA5 Support: Enum enumeration
JAVA7 Support: String type
Two choices of Java architecture