Decision Making in Java: Conditional Statements Explained

Day 16: Decision Making Or Conditional Statement A statement which helps a programmer in making decision whether to execute a block of code or not is known as Decision Making or Conditional Statement. Types of decision making statement 1.if statement 2.if-else statement 3.if-else ladder 4.switch statement 1.if statement: if is a decision making statement which helps a programmer to make a decision whether to execute a block of code or not. syntax: if(condition){ // statements } execution flow : statements inside if block gets execute when condition evaluate true. otherwise if block gets skip or ignored. 2.if-else Statement: if-else is a decision making statement which helps a programmer to make a decision whether to execute a block of code or not based on condition. else always associated with if. we can't add statement in between if and else block otherwise we get compile time error. syntax: if(condition){ // statements } else{ // statements } execution flow: if condition evaluate true then the statements associated with if block gets execute otherwise else block gets execute. #corejava #learning #java #post

  • diagram

To view or add a comment, sign in

Explore content categories