0% found this document useful (0 votes)
27 views

Decision Making: Etl Labs PVT LTD - Java Programming

The document discusses different conditional statements in Java programming including if, if-else, if-elseif-else, and switch statements. The if statement executes code if a condition is true. The if-else statement executes one code if the condition is true and another if it is false. The if-elseif-else statement checks multiple conditions and executes different code blocks. Finally, the switch statement selects one of many code blocks to execute based on different conditions.

Uploaded by

ETL LABS
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Decision Making: Etl Labs PVT LTD - Java Programming

The document discusses different conditional statements in Java programming including if, if-else, if-elseif-else, and switch statements. The if statement executes code if a condition is true. The if-else statement executes one code if the condition is true and another if it is false. The if-elseif-else statement checks multiple conditions and executes different code blocks. Finally, the switch statement selects one of many code blocks to execute based on different conditions.

Uploaded by

ETL LABS
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Decision Making

ETL LABS PVT LTD – JAVA PROGRAMMING 85


if Statement
The if statement executes some code if one
condition is true.

Syntax 1
if (condition)
{
code to be executed if condition
is true;
}

ETL LABS PVT LTD – JAVA PROGRAMMING 86


if...else Statement
The if....else statement executes some code
if a condition is true and another code if that
condition is false.

Syntax
2 if (condition)
{
code to be executed if condition is
true;
}
else
{
code to be executed if condition is
false;
}

ETL LABS PVT LTD – JAVA PROGRAMMING 87


if...elseif....else Statement
The if....elseif...else statement executes
different codes for more than two conditions.
Syntax
if (condition)
{
code to be executed if this condition
is true;
}
elseif (condition)
3
{
code to be executed if this condition
is true;
}
else
{
code to be executed if all conditions
are false;
}

ETL LABS PVT LTD – JAVA PROGRAMMING 88


switch Statement
The if....elseif...else statement executes different
codes for more than two conditions.
Use the switch statement to select one of
many blocks of code to be executed.
As shown in Syntax

ETL LABS PVT LTD – JAVA PROGRAMMING 89


Example of switch Statement

ETL LABS PVT LTD – JAVA PROGRAMMING 90

You might also like