Posts

Showing posts with the label if-else

Nested If in java

A nested if statement is an if-else statement with another if statement as the if body or the else body . Here conditions are evaluated from top to bottom . If  1st condition is true then the fist if statement will execute and if  1st condition is false then else if condition will check and rest of the process will move on one by one . If none of the above condition is match then else part will execute .  Syntax :           If(1st condition)           {                   // execute code           }           else if (2nd condition)           {               // execute code       ...

If else statement in java

If else statement is a most important part in decision making in Java . If else statement executes depend on boolean expression . If boolean expression is true the if statement will execute otherwise else . Syntax :               if(expression is true){                       //  execute statement                 }                else{                        //  execute statement                     } Example :             public class Dem...