24 Jan 2017

What is if-else condition statement in java..?

Hello guys guys today i will tell about the if -else condition statements

now as you know that the meaning of if in hindi (अगर ) so it works on Boolean expression under if brackets if the condition is true then the statements are execute under the curly braces other wise if the condition is false else part is execute ..

now lets study the syntax of if-else condition:


if(boolean-expression)      //if the condition is true 

//executes the statements under the braces
{statements}

//if the condition is false the else part is execute
else
{statements}


Lets take an example of if-else condition part:

class remote
{public static void main(String a[])
{int a=2;

if(a==2)   //if the condition is true
{System.out.println("You entered 2");}

//if the condition is false it execute else part
else {System.out.println("You did not entered 2");}
}}

if you execute the following program then the condition will be true because the value of variable a is 2 as in the condition if you change the value it execute the else part


click to  know deep about the for loop...
















No comments:

Post a Comment