The if is a keyword, which is used to perform the selection statement. It is used to execute the statements after evaluating the condition specified in it as true. When the condition is true, the code in the "if" block is executed. When false, the code in the if block is skipped. It starts a branching statement.
It is used to define a statement or block of statements that are executed in case, the test condition specified by the if keyword evaluates to true. When the if condition evaluates to true, the code after the if block is executed.
if is a java keyword that may not be used as identifiers i.e. you cannot
declare a variable or class with this name in your Java program. If an optional
block is defined with the
keyword, then the
block is executed when the test evaluates to false.
following shows the format of the if selection Construct syntax.
is an example of if keyword:
if (x > 1)
In the above example if we declare
int x = 1, the statements will show some of the valid boolean expressions to the
Posted on: November 11, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles