1 / 4

If-else

It is a block of statements where if a condition is true the block of statements is executed otherwise it would not be executed.

quipoin
Download Presentation

If-else

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. If-Else Conditional statements in JAVA

  2. Overview Conditional statements are fundamental programming constructs in Java that enable you to control the flow of a program based on specific conditions or criteria.  These statements allow you to make decisions and execute different blocks of code depending on whether a condition is true or false.  They are an essential part of programming as they enable you to create dynamic and flexible applications that can respond to changing circumstances.

  3. Program public class IfElseStatement { public static void main(String[] args) { int a = 10, int b = 20; if (a > b) { System.out.println("True"); } else { System.out.println("False"); } } }

  4. Types The main conditional statements used in Java are: if-else Statement: When a specified condition is true, a block of code is executed. If the condition is false, another block is executed. Switch Statement: It's useful for executing one of many code blocks based on an expression. Ternary Operator (Conditional Operator): It is a concise way to write if-else statements in one line. The condition is evaluated and one of two values is returned based on its truth value.

More Related