Skip to content
If Statement :-
- Conditional Statement are used to perform different action based on different condition.
- The if statement is one of the most frequently used conditional statements.
- If the if statement condition expression evaluates to true , the block inside the if statement is executed.
- If the expression found to be false , the set of code after the end of the if statement( after the closing curly brace) is executed.
- The if…else statement is an extension of the simple if statement.
- we have seen that when one of the many alternatives is to be selected , we can design a program using if statements to control the selection.
- However, the complexity of such a program increases dramatically when the number of alternatives increases.The program become difficult to read and follow.
- Fortunately, java has a built-in multiway decision statement known as switch.
- The switch statement tests the value of a given variable against a list of cases values and when a match is found, a block of statements associated with that case is executed.