GuidePedia

0




If else statement in java.


If else statement the other type of if statement .it execute one block of the statement when the condition is true and other when it false.in any situation, one block is executed and other is skipped in if else statement .if else statement executes statement for the true case if the Boolean expression evaluates to true. Otherwise, the statement for the false case is executed.
Both blocks of the statement can never be executed.
 Both blocks of the statement can never be skipped.






















Syntax.

If (condition)
Statement;
Else
Statement;
two more statement written in curly brackets {}.the syntax for compound statement in if else statement is as follows;
if(condition)
{
Statement 1;
Statement 2;
…statement n;
}
Flowchart.



















Example.
If(radius>=0)
{
Area=radius*radius*pi;
System.out.printin(“the area for the circle of radius”+radius + “is” +area);}
Else
{        system.out.printin(“negtive input”);
}

If the statement if(radius>=0) is true then the statement is executed.if the statement is false then displayed negative input.










































Related post.

Nested if else statement
If else statement in java
If statement in java
A simple program in java for begnners
 System.out.printin() in java
Public static void main ( String args[] ) in java program.
The basic structure of the java program.
Data types in java with examples(write and video tutorial
what is JVM(java virtual machine) java 8 features
What is Java programming and java history

Post a Comment

THANKS FOR COMMENT

 
Top