Java If ... Else
You know already Java supports the usual logical conditions from mathematics: java conditions Less than: a < b 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 You can use these conditions to perform different actions for different decisions. Java has the following conditional statements: If you want to tell a block of code to run only if a certain condition is true, use the if statement. If the same condition is false, use else to specify a block of code that should be executed. If the first condition is false, use else if to specify a new condition to test. To specify numerous different code blocks to be executed, use the switch command. The if Statement: If a condition is met, a block of Java code can be specified to run using the if statement true. Syntax if (condition) { // block of code to be executed if the condition is true } Note that if is in lowercase letter. UPPE...

Comments
Post a Comment