20CS304 Lecture 1: If Else Statements
Document Summary
You already know that java supports the usual logical conditions from mathematics: less than: ab, 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: use if to specify a block of code to be executed, Use the if statement to specify a block of java code to be executed if a condition is true. //block of code to be executed if the condition is true. Use the else statement to specify a block of code to be executed if the condition is false. // block of code to be executed if the condition is true. // block of code to be executed if the condition is false. Use the else if statement to specify a new condition if the first condition is false.