1. The if Loop:
It is one of most useful condition checking statement in java.
Syntax:
if(condition)
{
...................
statements;
..................
}
Make sure that the condition is always a Boolean statement. Other than a Boolean statement is not allowed in if loop.
If the Boolean statement is true, then only the loop body executes, otherwise skip the statement/statements associated with the loop.
Example:
int b = 6;
if (b%2!=0)
{
System.out.println("Value of b is an odd number");
}
Comments
Post a Comment