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
References
• https://docs.oracle.com/javase/tutorial/java/nutsandbolts/if.html
futuretekez@gmail.com
Keep In Touch
+94765632363
@FutureteKez
@10Giants

More Related Content

What's hot

Control statements in java
Control statements in javaControl statements in java
Control statements in java
Madishetty Prathibha
 
Control structures in java
Control structures in javaControl structures in java
Control structures in java
VINOTH R
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
Niloy Saha
 
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
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statements
Saad Sheikh
 
Loops Basics
Loops BasicsLoops Basics
Loops Basics
Mushiii
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
narmadhakin
 
Control structures i
Control structures i Control structures i
Control structures i
Ahmad Idrees
 
Variables and Data Types
Variables and Data TypesVariables and Data Types
Variables and Data Types
Infoviaan Technologies
 
Input and output in C++
Input and output in C++Input and output in C++
Input and output in C++
Nilesh Dalvi
 
Control flow statements in java
Control flow statements in javaControl flow statements in java
Control flow statements in java
yugandhar vadlamudi
 
While , For , Do-While Loop
While , For , Do-While LoopWhile , For , Do-While Loop
While , For , Do-While Loop
Abhishek Choksi
 
C# Exceptions Handling
C# Exceptions Handling C# Exceptions Handling
C# Exceptions Handling
sharqiyem
 
Abstract class and Interface
Abstract class and InterfaceAbstract class and Interface
Abstract class and Interface
Haris Bin Zahid
 
Templates in C++
Templates in C++Templates in C++
Templates in C++Tech_MX
 
Java constructors
Java constructorsJava constructors
Java constructors
QUONTRASOLUTIONS
 
Type Casting Operator
Type Casting OperatorType Casting Operator
Type Casting Operator
Infoviaan Technologies
 

What's hot (20)

Control statements in java
Control statements in javaControl statements in java
Control statements in java
 
Control structures in java
Control structures in javaControl structures in java
Control structures in java
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
 
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++
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statements
 
Operators in C++
Operators in C++Operators in C++
Operators in C++
 
Loops Basics
Loops BasicsLoops Basics
Loops Basics
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
 
Control structures i
Control structures i Control structures i
Control structures i
 
Variables and Data Types
Variables and Data TypesVariables and Data Types
Variables and Data Types
 
Input and output in C++
Input and output in C++Input and output in C++
Input and output in C++
 
Control flow statements in java
Control flow statements in javaControl flow statements in java
Control flow statements in java
 
While , For , Do-While Loop
While , For , Do-While LoopWhile , For , Do-While Loop
While , For , Do-While Loop
 
C# Exceptions Handling
C# Exceptions Handling C# Exceptions Handling
C# Exceptions Handling
 
Methods in Java
Methods in JavaMethods in Java
Methods in Java
 
Abstract class and Interface
Abstract class and InterfaceAbstract class and Interface
Abstract class and Interface
 
Java loops
Java loopsJava loops
Java loops
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
 
Java constructors
Java constructorsJava constructors
Java constructors
 
Type Casting Operator
Type Casting OperatorType Casting Operator
Type Casting Operator
 

Similar to Java if else condition - powerpoint persentation

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_selectionalish 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_selectionalish sha
 
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
 
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
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 ProgrammingPathomchon Sriwilairit
 
Data structures
Data structuresData structures
Data structures
Khalid Bana
 
JAVA PRACTICE QUESTIONS v1.4.pdf
JAVA PRACTICE QUESTIONS v1.4.pdfJAVA PRACTICE QUESTIONS v1.4.pdf
JAVA PRACTICE QUESTIONS v1.4.pdf
RohitkumarYadav80
 
130707833146508191
130707833146508191130707833146508191
130707833146508191
Tanzeel Ahmad
 

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

130706266060138191
130706266060138191130706266060138191
130706266060138191
 
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)
 
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
 
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
 
Comp102 lec 6
Comp102   lec 6Comp102   lec 6
Comp102 lec 6
 
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
 
201707 CSE110 Lecture 13
201707 CSE110 Lecture 13   201707 CSE110 Lecture 13
201707 CSE110 Lecture 13
 
control statement
control statement control statement
control statement
 
C Sharp Jn (3)
C Sharp Jn (3)C Sharp Jn (3)
C Sharp Jn (3)
 
L04 - Control Structuresjhgjhgjhgjhgfjgfjhgfjgf.pptx
L04 - Control Structuresjhgjhgjhgjhgfjgfjhgfjgf.pptxL04 - Control Structuresjhgjhgjhgjhgfjgfjhgfjgf.pptx
L04 - Control Structuresjhgjhgjhgjhgfjgfjhgfjgf.pptx
 
Loops
LoopsLoops
Loops
 
The Art of Clean Code
The Art of Clean CodeThe Art of Clean Code
The Art of Clean Code
 
C++ IF STATMENT AND ITS TYPE
C++ IF STATMENT AND ITS TYPEC++ IF STATMENT AND ITS TYPE
C++ IF STATMENT AND ITS TYPE
 
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
 
Practice
PracticePractice
Practice
 
JPC#8 Introduction to Java Programming
JPC#8 Introduction to Java ProgrammingJPC#8 Introduction to Java Programming
JPC#8 Introduction to Java Programming
 
Ann
AnnAnn
Ann
 
Data structures
Data structuresData structures
Data structures
 
JAVA PRACTICE QUESTIONS v1.4.pdf
JAVA PRACTICE QUESTIONS v1.4.pdfJAVA PRACTICE QUESTIONS v1.4.pdf
JAVA PRACTICE QUESTIONS v1.4.pdf
 
130707833146508191
130707833146508191130707833146508191
130707833146508191
 

More from Maneesha Caldera

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
 
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
Lesson 2
Lesson 2Lesson 2
Lesson 1
Lesson 1Lesson 1
Html 2
Html 2Html 2
Html 1
Html 1Html 1
Java arrays
Java arraysJava arrays
Java arrays
Maneesha Caldera
 

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
 
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
 
Presentation
PresentationPresentation
Presentation
 
Mobile cloud computing - Introduction
Mobile cloud computing - IntroductionMobile cloud computing - Introduction
Mobile cloud computing - Introduction
 
Android - Listview with source code
Android - Listview with source codeAndroid - Listview with source code
Android - Listview with source code
 
Java arrays
Java   arraysJava   arrays
Java arrays
 
React js Introduction
React js IntroductionReact js Introduction
React js Introduction
 
Android - Values folder
Android - Values folderAndroid - Values folder
Android - Values folder
 
Machine Learning - Supervised learning
Machine Learning - Supervised learningMachine Learning - Supervised learning
Machine Learning - Supervised learning
 
C# - Windows Forms - Creating exe file
C# - Windows Forms - Creating exe fileC# - Windows Forms - Creating exe file
C# - Windows Forms - Creating exe file
 
C# Memory management
C# Memory managementC# Memory management
C# Memory management
 
C# Strings
C# StringsC# Strings
C# Strings
 
C# - Windows forms - lesson 2
C# - Windows forms -  lesson 2C# - Windows forms -  lesson 2
C# - Windows forms - lesson 2
 
C# session 01
C# session 01C# session 01
C# session 01
 
Node
NodeNode
Node
 
Lesson 2
Lesson 2Lesson 2
Lesson 2
 
Lesson 1
Lesson 1Lesson 1
Lesson 1
 
Html 2
Html 2Html 2
Html 2
 
Html 1
Html 1Html 1
Html 1
 
Java arrays
Java arraysJava arrays
Java arrays
 

Recently uploaded

Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Enterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptxEnterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptx
QuickwayInfoSystems3
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
abdulrafaychaudhry
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 

Recently uploaded (20)

Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Enterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptxEnterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptx
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 

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
  • 17.