Java Conditions and If Statements
Java Conditions and If Statements
Java Conditions
•Less than: a < b
and If Statements
•Less than or equal to: a <= b
•Greater than: a > b
•Greater than or equal to: a >= b
•Equal to a == b
•Not Equal to: a != b
Java Java Conditions and If
Java If ... Else Statements
Java has the following conditional
You can use these statements:
conditions to
perform different Use if to specify a block of code to be
actions for different executed, if a specified condition is true
Use else to specify a block of code to be
decisions. executed, if the same condition is false
Use else if to specify a new condition to
test, if the first condition is false
Use switch to specify many alternative
blocks of code to be executed
Java
The if Statement
Java If ... Else
Use the if statement to Syntax
specify a block of Java
code to be executed if a if (condition) {
condition is true.
// block of code to be executed if the
condition is true