Thank You For Coming My Blog. This Blog is Everyone so You Read and Share another...

Friday, November 16, 2018

Java Decision Making

                                                         Java   Decision Making
There are two types of decision making statements in Java. They are:
  •  if statements
  • switch statements
The if Statement:
An if statement consists of a Boolean expression followed by one or more statements.
Syntax:
if(Boolean_expression)
{
//Statements will execute if the Boolean expression is true
}
If the  Boolean  expression evaluates to true,  then the block of code inside the if statement will be executed. If not,the first set of code after the end of the if statement(after the closing curly brace) will be executed.
The if...else Statement:
An  if  statement  can  be  followed  by  an  optional else statement,  which  executes  when  the  Boolean  expression  is false.
Syntax:
The syntax of an if...else is:
if(Boolean_expression){
//Executes when the Boolean expression is true
}else{
//Executes when the Boolean expression is false
}

No comments:

Post a Comment