Java If-else Statement
Sometimes we want to drink coffee when we feel sleepy. Sometimes, we order junk food if it is our friend’s birthday. You might want to buy an umbrella if it’s raining. All these decisions depend on a certain condition being met. Similar to real life, we can execute some instructions only when a condition is met in programming also. If-else block is used to check conditions and execute a particular section of code for a specific condition.
Flow control of if-else in Java :
Decision-making instructions in Java
Syntax of If-else statement in Java :
You can drive