Java if statement

  • by

In day to day life , sometimes our action depends on some condition being met. Example: If he has holiday, we will go for movie OR If it is raining , I will open the umbrella OR If I get job, I will give you party etc.

In java there are conditional statements which helps to perform action on some condition being met and those are listed below.

  1. if
  2. if else
  3. switch

if statement is used when you want to perform some on condition being met. if is implemented using keyword if. General form of if is given below:

If result of condition written in if is true or non zero then only statements written in curly braces of if gets executed.