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");
}
}
}
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhe5KGlonQ9y6loZXZ8vlR6sA12e6j61S20tnOye4qQWHtoyRNj9rSF-nRZzCF6hPydrdUn-pom7EVDESlw9w0llIn4HffAdF7UJKlyeS1I5t7GxQgkSEuts_aqV556UtW_YjINWtv1F3or/s400/if1.png)
==========================================
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");
}
}