If statement will executed in the code and check only if the condition is true.
Q.) W.A.P to print number is greater than or less than between ?
// Java program to illustrate If statement
class IfDemo {
public static void main(String args[])
{
int i = 10;
if (i < 15)
System.out.println("10 is less than 15");
System.out.println("Outside if-block");
// both statements will be printed
}
}
Output
10 is less than 15
Outside if-block