First, basic if structure
1. Flowchart
L Input/output
L Judging and branching
L Process Line
1.1 Simple if condition to judge
if ( expression ) {
// expression is true , execute the code in {}
}
1.2 Simple if condition to judge
if ( expression ) {
// expression is true , execute here
}else{
// expression is false , this line here
}
Description: If the If or else is followed by, and there is only one line of code, {} can be omitted, but it is not recommended to omit
L determine if strings are equal
A , case-sensitive: password
String Variables . Equals ( the value of a string or a string variable )
B , Case insensitive: Verification Code
String Variables . Equalsignorecase ( value of string or string variable )
How do I break down numbers in bits, 10, hundred, thousand?
Int digit = number% 10//decomposition get single digit
Int 10 bit = number/10 10//decomposition get 10 digits
Int hundred = number/100% 10//decomposition to get the number of hundred
INT thousand = number/1000% 10//Decomposition get thousand
Third, multiple if structure
if ( condition 1) {
// code block
}else if ( condition 2) {
// code block
}else if ( condition N) {
// code block
} else{
// code block
}
Description: An else if can have multiple, sequential requirements on the number range
Enter String--if in if (variable name. Equals ("string")) {}
Iv. Nested IF structures
if ( condition 1) {
// code block
I f ( condition 1-1) {
}
Description: The if structure can be a if , If...else , multiple if and other structures
} else{
can be for if , If...else , multiple if and other structures
}
Java Condition judgment