if / else if / else
Know how to write an if statement that includes else if and else blocks to control program flow.
if (condition){ } else if (next condition){ } else{ }The (condition) in the if statement above must be an expression that can be true or false. This is known as a boolean expression.
Some examples of a boolean expression are:
password.equals("password") school.equalsIgnoreCase ("The League") count == 10 count >= 33Notice that to test if a String variable contains a particular value, you need to use the equals or equalsIgnoreCase method, whereas for an int you can use ==
It is a good idea to always have an else block for an if statement, so you catch any condition you didn’t think of.