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 DemoTest {

                 public static void main(String args[]) {
                    int i = 10;

                    if( i > 8 ) {
                        System.out.print("Execute if statement");
                   }else {
                       System.out.print("Execute else statement");
                   }
               }
            }


Output :
                 Execute if statement


Find us :
        Facebook : @apnaandroid
        Google+   : Apna Java
        YouTube : Android & Java Tutorial

Comments

Popular posts from this blog

Disable/Hide Year from DatePickerDialog in android

Custom Calendar in android

Constructor in Java