Java : if else statement

Posted in Conditional Statements, Java By Raj On November 18, 2017

if-else statement 

The if-else statement is basic control flow statement for all programming languages, if you want to execute block of code based on the evaluation of certain condition is true then you can use if-else statement

The below code takes title as a method parameter if the title equals to hardcoded value which is “keysandstrokes” then the method will return true otherwise it returns false

In simple terminology, if else is a conditional statement if the condition is true to execute set of code or else execute another set of code


Java if else statement

Java if else statement



if statement

Java if statement

Java if statement

In the if statement, if the condition evaluates to true then execute the code which is in the curly braces

Nested If Statement


You can call if statement inside another if statement something like below