Home » Online Computer Education » Learn Fundamentals of Java Programming “Selection Structures in Java Programming ” Lesson 8
Learn Fundamentals of Java Programming “Selection Structures in Java Programming ” Lesson 8
Selection Structures
In real life, you often select your actions based on whether a condition is true or not. For example, if it is raining outside, you carry an umbrella, otherwise not.
Similarly in a program, you may want to execute a part of the program based on the value of an expression. Java provides two statements – the if else statement and the switch statement for executing a block of code conditionally (A block of code is a sequence of statements enclosed in curly braces).