More Examples: MathBits - Java - Conditionals
If statement Syntax
if (boolean expression) {
// the TRUE condition code goes here
}
Examples: 1.5.1 If Statement
if else statement Syntax
if (boolean expression) {
// the TRUE condition code goes here
}
else {
the FALSE condition code goes here
}
Examples: 1.5.2 If else
if else if ... statement Syntax
if (condition #1) {
// the TRUE condition #1 code goes here
} else if (condition #2) {
// the TRUE condition #2 code goes here
} else if (condition #3) {
// the TRUE condition #3 code goes here
} else {
// FALSE for All the above conditions code goes here
}
Example: 1.5.3 if else if Statement
Example: 1.5.4 Switch Statement