Monday, 2 November 2020

( if ..........else statement ) of JAVA

 

 

 

( if ..........else statement  ) of JAVA


An if statement can be followed  by an optional  else  statement , which  executes when the Boolean expression is false.


SYNTAX :-


if(Boolean_ expression )

    { 

         // Execute when  the Boolean  expression  is true

     }

else

     {

        // Executes  when  the Boolean expression  is faulse

 

       }


EXAMPLE :-

    

    

public class Test 

{

    public static void main (String args[])

   {

       int x =30;

       if ( x<20)


         {

              System .out.print("This  is if statement");


          }

else


        {

              System .out .print("This  is else statement");


           }


      }


}


OUTPUT :

This  is else statement




No comments:

Post a Comment

Student Marks Calculation app using java

      import javax.swing. *; import java.awt.event.ActionEvent ; import java.awt.event.ActionListener ; public class Student { private J...