One, save true or FALSE, use the Boolean variable
There are two values: True True
False false
Ii. accept input information from the console by creating a scanner
Scanner input New Scanner (system.in);
int age input.nextint ();//Receive int type
String Name=input.next ();//Receive Strin type
Third, relational operators
> < >= <= = = =!
Iv. the difference between = = and =
= comparison, = Assignment
V. Conditions of Judgment if
if (expression) {
Statement
}
When an expression is a true execution statement
The operators are divided into single-mesh operators, binocular operators, trinocular operators
Monocular operator:! ++ --
Binocular Operator: = +-*/% | | | & && = =
Trinocular operator:? : Example int sign= java>90?1:0;
Seven, logical operators
| & | | &&!
Priority order () >! > Arithmetic operator >&&>| | Assignment operator =
Multi-use () control priority
Eight, If-else
if (expression) {
Statement 1;
}else{
Statement 2;
}
When the expression is true, execute statement 1, when the expression is false, execute statement 2;
if (condition 1) {
statement 1;
}else if (condition 2) {
Statement 2
}else if (condition 3) {
Statement 3
}else
statement 4
}
ten, swicth (expression) {
case Value 1:
statement 1;
break;
Case value 2:
statement 2;
break;
default:
Statement 3;
break;
}
JDK versions above 1.7 or 1.7, the expression value can be string type;
value cannot be the same;
Break is the function of jumping out of the switch structure;
Xi. multiple if structures and switch structure use cases:
Multiple if judging interval value, switch judging equivalence
Java Chapter III Operators and conditional structure notes