Simple-if Statement in Java

simple-if Statement ?

This statement is used for testing a condition and excuting a part of code based on the result of the condition.
The condition shuld be a boolean expression which evaluates to either true or false.

 if(expression or condition)
}
..................
Statement;
}

The condition or test expression is evaluated.

If the result of the expression is true a bloack of statements will be executed.

If the result is false the program continues from the next statement after the if block.

Syntax :

 if (condition)
  {   .......
  	Statement;
      .......
  }
  

Example 1:



Output :

Number is positive.
This statement is always executed.

Example 2:



Output :

number is less than 100