Morash
04-10-2014, 01:08 AM
if else Statement In Java
This Is Another Form Of if Statement. It Is Used For Making Two Way Decisions.
In This Statement There Is One Condition And Two Statements.
If The Condition Is True The First Statement Is Executed And Second Statment Is Ignored.
And If The Condition Is False Then The Second Statement Is Executed And
First Statement Is Ignored.
Syntax:
if(condition)
{
statement 1 ;
}
else
{
statement 2;
}
Example:
Note: in.nextInt(); Is Used For Input Of Integer Type Value.
Whereas in.nextLine(); Is Used For Input Of String/Char Type Value.
http://i61.tinypic.com/10mlo2o.jpg
Output:
http://i59.tinypic.com/rsfvq0.jpg
This Is Another Form Of if Statement. It Is Used For Making Two Way Decisions.
In This Statement There Is One Condition And Two Statements.
If The Condition Is True The First Statement Is Executed And Second Statment Is Ignored.
And If The Condition Is False Then The Second Statement Is Executed And
First Statement Is Ignored.
Syntax:
if(condition)
{
statement 1 ;
}
else
{
statement 2;
}
Example:
Note: in.nextInt(); Is Used For Input Of Integer Type Value.
Whereas in.nextLine(); Is Used For Input Of String/Char Type Value.
http://i61.tinypic.com/10mlo2o.jpg
Output:
http://i59.tinypic.com/rsfvq0.jpg