if statement in java

In the previous post, we have seen the working of for each loop in java. In this post, we will look at if statement in java.

In every programming language, at some point we need to put few conditions check or verification. if statement is used to to verify the conditions, that’s why it is called conditional statement. After condition check, it evaluates boolean value like true or false. If true, it enters the if statement block and performs necessary tasks, else exit the conditional statement.

Syntax of if statement:

Example of if statement:

Output: Value of a : 100

if ..else statement:

We can perform different tasks on the basis of conditions evaluation like true or false. For that we can associate else statement with if statement. 

Example of if ..else:

Output: Value of a is not less that actual value: 100
Have any question or suggestion for us?Please feel free to post in Q&A Forum
for each loop in java
elseif statement in java
Shekhar Sharma

Shekhar Sharma

Shekhar Sharma is founder of testingpool.com. This website is his window to the world. He believes that ,"Knowledge increases by sharing but not by saving".

You may also like...

2 Responses

  1. August 10, 2015

    […] the previous post, we have seen if else statement. In this post, we will learn about elseif […]

  2. August 10, 2015

    […] In the previous post, we have seen the conditional statements. […]