Scanner
corresponds to the scanner, i.e., the user can scan Scanner class entered in the console and receive data.
Usage:
flow control classification structure:
- Sequence Structure
- Selecting (determining) the structure
- Loop structure
Sequence Structure
code from top to bottom, left to right, line by line sequentially performed
Selecting (determining) the structure of
selecting different code depending on the condition to execute the code structure.
The main non-into two categories:
- The if statement
- switch statement
if statement in three formats:
. 1,
if (relational expression) {
// statements member
}
2,
IF (relational expression) {
// statements body. 1
} the else {
// statements 2
}
. 3,
IF (relational expression 1) {
// statements body 1
} the else IF (relational expression 2) {
// statements body 2
} // ...
the else {
// statements body 1 + n-
}
format switch statement
switch (expression) {
Case. 1:
statement body. 1;
BREAK;
Case 2:
; statement body 2
BREAK;
...
default:
statement body. 1 + n-;
BREAK;
}