Java Tutorial - 17 - If else Statement - Study Viral
Decision Making Statements (if-else)
The if-then statement is the most simple control flow statements. It helps your program to execute a certain block of code only if a particular test evaluates to true.
Type of if-else
if Statement
if else Statement
if else if Statement
Nested if - else
The if-then statement is the most simple control flow statements. It helps your program to execute a certain block of code only if a particular test evaluates to true.
Type of if-else
if Statement
if else Statement
if else if Statement
Nested if - else
===================================
class DecisionMaking{
public static void main(String []args){
if(true){
System.out.println("Yes its true");
}
System.out.println("Out side if ");
if(false){
System.out.println("Yes its again true");
System.out.println("out side if");
}
}
}
public static void main(String []args){
if(true){
System.out.println("Yes its true");
}
System.out.println("Out side if ");
if(false){
System.out.println("Yes its again true");
System.out.println("out side if");
}
}
}
==========================================
class DecisionMaking{
public static void main(String []args){
int a = 10;
int b = 20;
boolean bb = true;
Boolean bool = true;
if(bool){
System.out.println("Wow if can accept Wrapper Class object");
} else if((a>b) && bb){
System.out.println("Yes its true");
System.out.println("Yes a > b");
}else{
System.out.println("Yes its else part");
}
System.out.println("From Outside");
}
}
public static void main(String []args){
int a = 10;
int b = 20;
boolean bb = true;
Boolean bool = true;
if(bool){
System.out.println("Wow if can accept Wrapper Class object");
} else if((a>b) && bb){
System.out.println("Yes its true");
System.out.println("Yes a > b");
}else{
System.out.println("Yes its else part");
}
System.out.println("From Outside");
}
}
=================================================
class DecisionMaking{
public static void main(String []args){
int a = 10;
int b = 20;
boolean bb = true;
Boolean bool = new Boolean(false); //Wrapper Class Object
if(bool){
System.out.println("Wow if can accept Wrapper Class object");
} else if((a<b) && bb){
System.out.println("Yes its true");
System.out.println("Yes a > b");
}else{
System.out.println("Yes its else part");
}
System.out.println("From Outside");
}
}
public static void main(String []args){
int a = 10;
int b = 20;
boolean bb = true;
Boolean bool = new Boolean(false); //Wrapper Class Object
if(bool){
System.out.println("Wow if can accept Wrapper Class object");
} else if((a<b) && bb){
System.out.println("Yes its true");
System.out.println("Yes a > b");
}else{
System.out.println("Yes its else part");
}
System.out.println("From Outside");
}
}