SlideShare a Scribd company logo
if else condition
Syntax
if (condition) {
// block of code to be executed if the condition is true
}
eg:-
if(true){
System.out.println("This code executed");
}
Example 1
System.out.println("Before if condition");
if(true){
System.out.println("This code executed");
}
System.out.println("After If condition");
Example 2
System.out.println("Before if condition");
if(false){
System.out.println("This code not executed");
}
System.out.println("After If condition");
Example 3
int number = 10;
System.out.println("Before if condition");
if(number > 0 ){
System.out.println("Positive value found");
}
System.out.println("After If condition");
Example 4
int number = -10;
System.out.println("Before if condition");
if(number < 0 ){
System.out.println("Negative value found");
}
System.out.println("After If condition");
Example 5
int number = 10;
System.out.println("Before if condition");
if(number == 10 ){
System.out.println("number is equal to 10");
}
System.out.println("After If condition");
Example 6
int number = 100;
System.out.println("Before if condition");
if(number != 10 ){
System.out.println("number is not equal to 10");
}
System.out.println("After If condition");
Example 7
int number = 100;
System.out.println("Before if condition");
if(number > 10 ){
System.out.println("number is larger than 10");
}else{
System.out.println("number is less than 10");
}
System.out.println("After If condition");
Example 8
int x = 30;
if( x == 10 ) {
System.out.print("Value of X is 10");
}else if( x == 20 ) {
System.out.print("Value of X is 20");
}else if( x == 30 ) {
System.out.print("Value of X is 30");
}else {
System.out.print("This is else statement");
}
Example 9
int number = 10;
System.out.println("Before if condition");
if(number != 10 ){
System.out.println("number is not equal to 10");
}else{
System.out.println("number is equal to 10");
}
System.out.println("After If condition");
Example 10
int number = 100;
System.out.println("Before if condition");
if(number > 10 ){
System.out.println("number is larger than 10");
}else if(number >50){
System.out.println("number is larger than 50");
}else{
System.out.println("number is smaller than 10");
}
System.out.println("After If condition");
In Class Activity
●Develop the code to check following conditions
●if number is larger than 50 no need to check is that larger than 10
●if the number is between 10 and 50 then application should print "Number
is larger than 10 and less than 50"
Example 11
int number = 100;
System.out.println("Before if condition");
if(number > 10 ){
System.out.println("number is larger than 10");
if(number >50){
System.out.println("number is larger than 50");
}
else{
System.out.println("number is smaller than 10");
}
System.out.println("After If condition");
In class Activity
Compress the above code
Quiz
Java if else condition - powerpoint persentation
References
• https://docs.oracle.com/javase/tutorial/java/nutsandbolts/if.html
futuretekez@gmail.com
Keep In Touch
+94765632363
@FutureteKez
@10Giants
Ad

More Related Content

What's hot (20)

Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
kamal kotecha
 
Final keyword in java
Final keyword in javaFinal keyword in java
Final keyword in java
Lovely Professional University
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in Java
Spotle.ai
 
Collection Framework in java
Collection Framework in javaCollection Framework in java
Collection Framework in java
CPD INDIA
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
Intelligo Technologies
 
Type casting in java
Type casting in javaType casting in java
Type casting in java
Farooq Baloch
 
for loop in java
for loop in java for loop in java
for loop in java
Majid Ali
 
6. static keyword
6. static keyword6. static keyword
6. static keyword
Indu Sharma Bhardwaj
 
C++ Arrays
C++ ArraysC++ Arrays
C++ Arrays
أحمد محمد
 
Java Arrays
Java ArraysJava Arrays
Java Arrays
Jussi Pohjolainen
 
Exception Handling in JAVA
Exception Handling in JAVAException Handling in JAVA
Exception Handling in JAVA
SURIT DATTA
 
Java Collections Framework
Java Collections FrameworkJava Collections Framework
Java Collections Framework
Sony India Software Center
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
narmadhakin
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
Abhilash Nair
 
Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
Madishetty Prathibha
 
An Introduction to Programming in Java: Arrays
An Introduction to Programming in Java: ArraysAn Introduction to Programming in Java: Arrays
An Introduction to Programming in Java: Arrays
Martin Chapman
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
rprajat007
 
Sql subquery
Sql  subquerySql  subquery
Sql subquery
Raveena Thakur
 
Python Basics
Python BasicsPython Basics
Python Basics
tusharpanda88
 
Java(Polymorphism)
Java(Polymorphism)Java(Polymorphism)
Java(Polymorphism)
harsh kothari
 

Similar to Java if else condition - powerpoint persentation (20)

130706266060138191
130706266060138191130706266060138191
130706266060138191
Tanzeel Ahmad
 
Find the output of the following code (Java for ICSE)
Find the output of the following code (Java for ICSE)Find the output of the following code (Java for ICSE)
Find the output of the following code (Java for ICSE)
Mokshya Priyadarshee
 
Dti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionDti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selection
alish sha
 
Dti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionDti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selection
alish sha
 
java programming language part-2 decision making .pdf
java programming language part-2 decision making .pdfjava programming language part-2 decision making .pdf
java programming language part-2 decision making .pdf
AbhishekSingh961152
 
Comp102 lec 6
Comp102   lec 6Comp102   lec 6
Comp102 lec 6
Fraz Bakhsh
 
Java Chapter 05 - Conditions & Loops: part 3
Java Chapter 05 - Conditions & Loops: part 3Java Chapter 05 - Conditions & Loops: part 3
Java Chapter 05 - Conditions & Loops: part 3
DanWooster1
 
201707 CSE110 Lecture 13
201707 CSE110 Lecture 13   201707 CSE110 Lecture 13
201707 CSE110 Lecture 13
Javier Gonzalez-Sanchez
 
control statement
control statement control statement
control statement
Kathmandu University
 
Introduction to Selection control structures in C++
Introduction to Selection control structures in C++ Introduction to Selection control structures in C++
Introduction to Selection control structures in C++
Neeru Mittal
 
C Sharp Jn (3)
C Sharp Jn (3)C Sharp Jn (3)
C Sharp Jn (3)
jahanullah
 
L04 - Control Structuresjhgjhgjhgjhgfjgfjhgfjgf.pptx
L04 - Control Structuresjhgjhgjhgjhgfjgfjhgfjgf.pptxL04 - Control Structuresjhgjhgjhgjhgfjgfjhgfjgf.pptx
L04 - Control Structuresjhgjhgjhgjhgfjgfjhgfjgf.pptx
EliasPetros
 
Loops
LoopsLoops
Loops
Kamran
 
The Art of Clean Code
The Art of Clean CodeThe Art of Clean Code
The Art of Clean Code
Yael Zaritsky Perez
 
C++ IF STATMENT AND ITS TYPE
C++ IF STATMENT AND ITS TYPEC++ IF STATMENT AND ITS TYPE
C++ IF STATMENT AND ITS TYPE
UNIVERSITY OF ENGINEERING AND TECHNOLOGY TAXILA
 
import java.util.Scanner;public class Main {private static i.pdf
import java.util.Scanner;public class Main {private static i.pdfimport java.util.Scanner;public class Main {private static i.pdf
import java.util.Scanner;public class Main {private static i.pdf
stopgolook
 
Practice
PracticePractice
Practice
Daman Toor
 
JPC#8 Introduction to Java Programming
JPC#8 Introduction to Java ProgrammingJPC#8 Introduction to Java Programming
JPC#8 Introduction to Java Programming
Pathomchon Sriwilairit
 
Ann
AnnAnn
Ann
micro536
 
Data structures
Data structuresData structures
Data structures
Khalid Bana
 
Find the output of the following code (Java for ICSE)
Find the output of the following code (Java for ICSE)Find the output of the following code (Java for ICSE)
Find the output of the following code (Java for ICSE)
Mokshya Priyadarshee
 
Dti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionDti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selection
alish sha
 
Dti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionDti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selection
alish sha
 
java programming language part-2 decision making .pdf
java programming language part-2 decision making .pdfjava programming language part-2 decision making .pdf
java programming language part-2 decision making .pdf
AbhishekSingh961152
 
Java Chapter 05 - Conditions & Loops: part 3
Java Chapter 05 - Conditions & Loops: part 3Java Chapter 05 - Conditions & Loops: part 3
Java Chapter 05 - Conditions & Loops: part 3
DanWooster1
 
Introduction to Selection control structures in C++
Introduction to Selection control structures in C++ Introduction to Selection control structures in C++
Introduction to Selection control structures in C++
Neeru Mittal
 
C Sharp Jn (3)
C Sharp Jn (3)C Sharp Jn (3)
C Sharp Jn (3)
jahanullah
 
L04 - Control Structuresjhgjhgjhgjhgfjgfjhgfjgf.pptx
L04 - Control Structuresjhgjhgjhgjhgfjgfjhgfjgf.pptxL04 - Control Structuresjhgjhgjhgjhgfjgfjhgfjgf.pptx
L04 - Control Structuresjhgjhgjhgjhgfjgfjhgfjgf.pptx
EliasPetros
 
import java.util.Scanner;public class Main {private static i.pdf
import java.util.Scanner;public class Main {private static i.pdfimport java.util.Scanner;public class Main {private static i.pdf
import java.util.Scanner;public class Main {private static i.pdf
stopgolook
 
JPC#8 Introduction to Java Programming
JPC#8 Introduction to Java ProgrammingJPC#8 Introduction to Java Programming
JPC#8 Introduction to Java Programming
Pathomchon Sriwilairit
 
Ad

More from Maneesha Caldera (20)

An Overview of Social media analatics
An Overview of Social media analaticsAn Overview of Social media analatics
An Overview of Social media analatics
Maneesha Caldera
 
What is the programming language you need to learn
What is the programming language you need to learnWhat is the programming language you need to learn
What is the programming language you need to learn
Maneesha Caldera
 
Presentation
PresentationPresentation
Presentation
Maneesha Caldera
 
Mobile cloud computing - Introduction
Mobile cloud computing - IntroductionMobile cloud computing - Introduction
Mobile cloud computing - Introduction
Maneesha Caldera
 
Android - Listview with source code
Android - Listview with source codeAndroid - Listview with source code
Android - Listview with source code
Maneesha Caldera
 
Java arrays
Java   arraysJava   arrays
Java arrays
Maneesha Caldera
 
React js Introduction
React js IntroductionReact js Introduction
React js Introduction
Maneesha Caldera
 
Android - Values folder
Android - Values folderAndroid - Values folder
Android - Values folder
Maneesha Caldera
 
Machine Learning - Supervised learning
Machine Learning - Supervised learningMachine Learning - Supervised learning
Machine Learning - Supervised learning
Maneesha Caldera
 
C# - Windows Forms - Creating exe file
C# - Windows Forms - Creating exe fileC# - Windows Forms - Creating exe file
C# - Windows Forms - Creating exe file
Maneesha Caldera
 
C# Memory management
C# Memory managementC# Memory management
C# Memory management
Maneesha Caldera
 
C# Strings
C# StringsC# Strings
C# Strings
Maneesha Caldera
 
C# - Windows forms - lesson 2
C# - Windows forms -  lesson 2C# - Windows forms -  lesson 2
C# - Windows forms - lesson 2
Maneesha Caldera
 
C# session 01
C# session 01C# session 01
C# session 01
Maneesha Caldera
 
Node
NodeNode
Node
Maneesha Caldera
 
Lesson 2
Lesson 2Lesson 2
Lesson 2
Maneesha Caldera
 
Lesson 1
Lesson 1Lesson 1
Lesson 1
Maneesha Caldera
 
Html 2
Html 2Html 2
Html 2
Maneesha Caldera
 
Html 1
Html 1Html 1
Html 1
Maneesha Caldera
 
Java arrays
Java arraysJava arrays
Java arrays
Maneesha Caldera
 
Ad

Recently uploaded (20)

Not So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java WebinarNot So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java Webinar
Tier1 app
 
Full Cracked Resolume Arena Latest Version
Full Cracked Resolume Arena Latest VersionFull Cracked Resolume Arena Latest Version
Full Cracked Resolume Arena Latest Version
jonesmichealj2
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
Tools of the Trade: Linux and SQL - Google Certificate
Tools of the Trade: Linux and SQL - Google CertificateTools of the Trade: Linux and SQL - Google Certificate
Tools of the Trade: Linux and SQL - Google Certificate
VICTOR MAESTRE RAMIREZ
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Top 10 Data Cleansing Tools for 2025.pdf
Top 10 Data Cleansing Tools for 2025.pdfTop 10 Data Cleansing Tools for 2025.pdf
Top 10 Data Cleansing Tools for 2025.pdf
AffinityCore
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
saimabibi60507
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Innovative Approaches to Software Dev no good at all
Innovative Approaches to Software Dev no good at allInnovative Approaches to Software Dev no good at all
Innovative Approaches to Software Dev no good at all
ayeshakanwal75
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
Implementing promises with typescripts, step by step
Implementing promises with typescripts, step by stepImplementing promises with typescripts, step by step
Implementing promises with typescripts, step by step
Ran Wahle
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
Microsoft Excel Core Points Training.pptx
Microsoft Excel Core Points Training.pptxMicrosoft Excel Core Points Training.pptx
Microsoft Excel Core Points Training.pptx
Mekonnen
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Not So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java WebinarNot So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java Webinar
Tier1 app
 
Full Cracked Resolume Arena Latest Version
Full Cracked Resolume Arena Latest VersionFull Cracked Resolume Arena Latest Version
Full Cracked Resolume Arena Latest Version
jonesmichealj2
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
Tools of the Trade: Linux and SQL - Google Certificate
Tools of the Trade: Linux and SQL - Google CertificateTools of the Trade: Linux and SQL - Google Certificate
Tools of the Trade: Linux and SQL - Google Certificate
VICTOR MAESTRE RAMIREZ
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Top 10 Data Cleansing Tools for 2025.pdf
Top 10 Data Cleansing Tools for 2025.pdfTop 10 Data Cleansing Tools for 2025.pdf
Top 10 Data Cleansing Tools for 2025.pdf
AffinityCore
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
saimabibi60507
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Innovative Approaches to Software Dev no good at all
Innovative Approaches to Software Dev no good at allInnovative Approaches to Software Dev no good at all
Innovative Approaches to Software Dev no good at all
ayeshakanwal75
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
Implementing promises with typescripts, step by step
Implementing promises with typescripts, step by stepImplementing promises with typescripts, step by step
Implementing promises with typescripts, step by step
Ran Wahle
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
Microsoft Excel Core Points Training.pptx
Microsoft Excel Core Points Training.pptxMicrosoft Excel Core Points Training.pptx
Microsoft Excel Core Points Training.pptx
Mekonnen
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 

Java if else condition - powerpoint persentation

  • 2. Syntax if (condition) { // block of code to be executed if the condition is true } eg:- if(true){ System.out.println("This code executed"); }
  • 3. Example 1 System.out.println("Before if condition"); if(true){ System.out.println("This code executed"); } System.out.println("After If condition");
  • 4. Example 2 System.out.println("Before if condition"); if(false){ System.out.println("This code not executed"); } System.out.println("After If condition");
  • 5. Example 3 int number = 10; System.out.println("Before if condition"); if(number > 0 ){ System.out.println("Positive value found"); } System.out.println("After If condition");
  • 6. Example 4 int number = -10; System.out.println("Before if condition"); if(number < 0 ){ System.out.println("Negative value found"); } System.out.println("After If condition");
  • 7. Example 5 int number = 10; System.out.println("Before if condition"); if(number == 10 ){ System.out.println("number is equal to 10"); } System.out.println("After If condition");
  • 8. Example 6 int number = 100; System.out.println("Before if condition"); if(number != 10 ){ System.out.println("number is not equal to 10"); } System.out.println("After If condition");
  • 9. Example 7 int number = 100; System.out.println("Before if condition"); if(number > 10 ){ System.out.println("number is larger than 10"); }else{ System.out.println("number is less than 10"); } System.out.println("After If condition");
  • 10. Example 8 int x = 30; if( x == 10 ) { System.out.print("Value of X is 10"); }else if( x == 20 ) { System.out.print("Value of X is 20"); }else if( x == 30 ) { System.out.print("Value of X is 30"); }else { System.out.print("This is else statement"); }
  • 11. Example 9 int number = 10; System.out.println("Before if condition"); if(number != 10 ){ System.out.println("number is not equal to 10"); }else{ System.out.println("number is equal to 10"); } System.out.println("After If condition");
  • 12. Example 10 int number = 100; System.out.println("Before if condition"); if(number > 10 ){ System.out.println("number is larger than 10"); }else if(number >50){ System.out.println("number is larger than 50"); }else{ System.out.println("number is smaller than 10"); } System.out.println("After If condition");
  • 13. In Class Activity ●Develop the code to check following conditions ●if number is larger than 50 no need to check is that larger than 10 ●if the number is between 10 and 50 then application should print "Number is larger than 10 and less than 50"
  • 14. Example 11 int number = 100; System.out.println("Before if condition"); if(number > 10 ){ System.out.println("number is larger than 10"); if(number >50){ System.out.println("number is larger than 50"); } else{ System.out.println("number is smaller than 10"); } System.out.println("After If condition");
  • 15. In class Activity Compress the above code
  • 16. Quiz