IF Else
IF Else : The If else statement is a powerful decision making statement and is used to control the flow of execution of statements. It is basically a two way decision statement and is used in conjunction with an expression.
Program Illustration for If Else :
Class ifelsenesting
{
Public static void main(String args[])
{
Int a = 325, b = 712, c = 476;
System.out.print(“Largest Value is “);
If(a >b)
{
If(a>c)
{
System.out.print(a);
}
Else {
System.out.print©;
}
}
else{
if ( c > b)
{
System.out.println©;
}
Else{
{
System.out.println(b);
}
}
}
}
Note :The println("...") method prints the string "..." and moves the cursor to a new line. The print("...") method instead prints just the string "...", but does not move the cursor to a new line. Hence, subsequent printing instructions will print on the same line. The println() method can also be used without parameters, to position the cursor on the next line.