First, basic if structure
1. Flowchart
Input/Output
Judging and branching
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
Second, logical operators
&& Logic and (press shift+7)--and (and, at the same time)
Multiple conditions, 1 are false, if () all false, multiple conditions are true at the same time, if () is true
|| (Press shift+ to enter the above |) -or (OR)
Multiple conditions, as long as 1 are true, if () all is true
! (in English state)--Take the inverse not equal to! =
determine if strings are equal
A , case-sensitive: password
String Variables . equals ( value of string or 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? "P47"
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
in the I f Input String--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 Foundation Chapter III