java programming- control statements
 java programming- control statements
 java programming- control statements
 java programming- control statements
It is used to take decision based on a single condition
Syntax:
False
True

If condition is True; control will enter the if block
If condition is False; control will execute statement followed by if block
Flow Chart:
True

False
Example: Read marks from user and state only if user is pass.
It is used to take decision based on a single condition
Syntax:
True

False
Flow Chart:
True

False
The if else statement has one condition and two statement blocksTrue block and False block
If condition is True; control will execute the statement in the true block
If condition is False; control will execute the statement in false block
Example: Read marks from user and state whether student is Pass or Fail
It is used to take decision based on two conditions.
Syntax:
Flow Chart:
True

False

If within else
Example:
The Nested if can be inside the if-part or else-part
Syntax:
Flow Chart:
True

False

If within else
Flow Chart:
True

False

If within else
Example:
Example:
A switch statement is used to test many conditions
Syntax:
Flow Chart:

Start

Variable or Expression
Case A Statements

Case A
True
False

Case B Statements

Case B
True
False

Case C Statements

…
True
False

default

End

Default Statements
Flow Chart:

Start

Variable or Expression
Case A
True

Case A Statements
break;

False

Case B
True

Case B Statements
break;

False

…
True

Case C Statements
break;

False

default

End

Default Statements
Example:
 java programming- control statements
 java programming- control statements
 java programming- control statements
-Initialization
-Condition checking
-Execution
-Increment / Decrement
 java programming- control statements
 java programming- control statements
Entry Controlled

Exit Controlled

Condition is checked at the entry of the
loop

Condition is checked at the exit of the
loop

If condition is initially false, the loop
never executes

If condition is initially false, then also the
loop executes at least once

i=1;
while(i==0)
{
System.out.println(“In While loop”);
}
System.out.println(“out of the loop”);

i=1;
do
{
System.out.println(“In While loop”);
} while(i==0);
System.out.println(“out of the loop”);

Output:
Out of the loop

Output:
In while loop
Out of the loop

Example- for, while

Example – do-while
 java programming- control statements
 java programming- control statements
 java programming- control statements
Initialization Statement is used
to initialize a variable/ counter.
The condition statement controls
the execution of loop
The loop executes till
condition statement is true

the
The execution statements are
the main body of a loop
All action statements of loop
are written here
This section is used to
increment or decrement
the variable value
Output
1
i

Variable i in memory
Output
1
i

Variable i in memory

Condition
is True
Output
1
1
i

Variable i in memory

Check it
out here
Check it
out here

Output
1

2
i

Variable i in memory
Output
1
2
i

Variable i in memory

Condition is
checked again
Output
1
2
i

Variable i in memory

Condition
is True
Output
2
i

Variable i in memory

1
2

Check it
out here
Check it
out here
3
i

Variable i in memory

Output
1
2
Output
3
i

Variable i in memory

1
2

Condition is
checked again
Output
3
i

Variable i in memory

1
2

Condition
is True
Output
3
i

Variable i in memory

1
2
3

Check it
out here
Check it
out here
4
i

Variable i in memory

Output
1
2
3
Output
4
i

Variable i in memory

1
2
3

Condition is
checked again
Output
4
i

Variable i in memory

1
2
3

Condition
is True
Output
4
i

Variable i in memory

1
2
3
4

Check it
out here
Check it
out here
5
i

Variable i in memory

Output
1
2
3
4
Output
5
i

Variable i in memory

1
2
3
4

Condition is
checked again
This process will continue till the condition become false

Suppose value of i is 9 now
Output
9
i

Variable i in memory

1
2
3
4
5
6
7
8

Condition
is True
Output
9
i

Variable i in memory

1
2
3
4
5
6
7
8
9

Check it
out here
Check it
out here
10
i

Variable i in memory

Output
1
2
3
4
5
6
7
8
9
Output
10
i

Variable i in memory

1
2
3
4
5
6
7
8
9

Condition is
checked again
Output
10
i

Variable i in memory

1
2
3
4
5
6
7
8
9

Condition
is Still True
Output
10
i

Variable i in memory

1
2
3
4
5
6
7
8
9
10

Check it
out here
Check it
out here
11
i

Variable i in memory

Output
1
2
3
4
5
6
7
8
9
10
Output
11
i

Variable i in memory

1
2
3
4
5
6
7
8
9
10

Condition is
checked again
Output
11
i

Variable i in memory

1
2
3
4
5
6
7
8
9
10

Condition
is FALSE
Output
11
i

Variable i in memory

Skip the body of
the lop and
executes the
statement jast
after the loop

1
2
3
4
5
6
7
8
9
10
Final value of i
after the
complete loop Output
11
i

Variable i in memory

1
2
3
4
5
6
7
8
9
10
Output
11
i

Variable i in memory

1
2
3
4
5
6
7
8
9
10

Final output of
the loop
 java programming- control statements
 java programming- control statements
 java programming- control statements
Initialization Statement is used to initialize a variable/ counter.
The condition statement controls the execution of loop
The loop executes till the condition statement is true
This section is used to increment or decrement the variable value
The execution statements are the main body of a loop
All action statements of loop are written here
Output
1
i

Variable i in memory

Initialization
Output
1
i

Variable i in memory

Condition
is True
Check it
out here
Output
1
1
i

Variable i in memory
Check it
out here

increment
Output
1

2
i

Variable i in memory
Output
1
2
i

Variable i in memory

Condition is
checked again
Output
1
2
i

Variable i in memory

Condition
is True
Output
2
i

Variable i in memory

1
2

Check it
out here
Check it
out here
3
i

Variable i in memory

Output
1
2
Output
3
i

Variable i in memory

1
2

Condition is
checked again
Output
3
i

Variable i in memory

1
2

Condition
is True
Output
3
i

Variable i in memory

1
2
3

Check it
out here
Check it
out here
4
i

Variable i in memory

Output
1
2
3
Output
4
i

Variable i in memory

1
2
3

Condition is
checked again
Output
4
i

Variable i in memory

1
2
3

Condition
is True
Output
4
i

Variable i in memory

1
2
3
4

Check it
out here
Check it
out here
5
i

Variable i in memory

Output
1
2
3
4
Output
5
i

Variable i in memory

1
2
3
4

Condition is
checked again
This process will continue till the condition become false

Suppose value of i is 9 now
Output
9
i

Variable i in memory

1
2
3
4
5
6
7
8

Condition
is True
Output
9
i

Variable i in memory

1
2
3
4
5
6
7
8
9

Check it
out here
Check it
out here
10
i

Variable i in memory

Output
1
2
3
4
5
6
7
8
9
Output
10
i

Variable i in memory

1
2
3
4
5
6
7
8
9

Condition is
checked again
Output
10
i

Variable i in memory

1
2
3
4
5
6
7
8
9

Condition
is Still True
Output
10
i

Variable i in memory

1
2
3
4
5
6
7
8
9
10

Check it
out here
Check it
out here
11
i

Variable i in memory

Output
1
2
3
4
5
6
7
8
9
10
Output
11
i

Variable i in memory

1
2
3
4
5
6
7
8
9
10

Condition is
checked again
Output
11
i

Variable i in memory

1
2
3
4
5
6
7
8
9
10

Condition
is FALSE
Output
11
i

Variable i in memory

Skip the body of
the lop and
executes the
statement just
after the loop

1
2
3
4
5
6
7
8
9
10
Final value of i
after the
complete loop Output
11
i

Variable i in memory

1
2
3
4
5
6
7
8
9
10
Output
11
i

Variable i in memory

1
2
3
4
5
6
7
8
9
10

Final output of
the loop
 java programming- control statements
 java programming- control statements
 java programming- control statements
Initialization Statement is used
to initialize a variable/ counter.
The condition statement controls
the execution of loop
The loop executes till
condition statement is true

the
The execution statements are
the main body of a loop
All action statements of loop
are written here
This section is used to
increment or decrement
the variable value
Output
1
i

Variable i in memory
Output
1
i

Variable i in memory

No condition
checking at entry of
the loop
Output
1
1
i

Variable i in memory

Check it
out here
Check it
out here

Output
1

2
i

Variable i in memory
Output
1
2
i

Variable i in memory

Condition is
checked again
Output
1
2
i

Variable i in memory

Condition
is True
Output
2
i

Variable i in memory

1
2

Check it
out here
Check it
out here
3
i

Variable i in memory

Output
1
2
Output
3
i

Variable i in memory

1
2
Condition is
checked again
Output
3

1
2

i

Variable i in memory

Condition
is True
Output
3
i

Variable i in memory

1
2
3

Check it
out here
Check it
out here
4
i

Variable i in memory

Output
1
2
3
Output
4
i

Variable i in memory

1
2
3

Condition is
checked again
Output
4
i

Variable i in memory

1
2
3

Condition
is True
Output
4
i

Variable i in memory

1
2
3
4

Check it
out here
Check it
out here
5
i

Variable i in memory

Output
1
2
3
4
Output
5
i

Variable i in memory

1
2
3
4

Condition is
checked again
This process will continue till the condition become false

Suppose value of i is 9 now
Output
9
i

Variable i in memory

1
2
3
4
5
6
7
8

Condition
is True
Output
9
i

Variable i in memory

1
2
3
4
5
6
7
8
9

Check it
out here
Check it
out here
10
i

Variable i in memory

Output
1
2
3
4
5
6
7
8
9
Output
10
i

Variable i in memory

1
2
3
4
5
6
7
8
9

Condition is
checked again
Output
10
i

Variable i in memory

1
2
3
4
5
6
7
8
9

Condition
is Still True
Output
10
i

Variable i in memory

1
2
3
4
5
6
7
8
9
10

Check it
out here
Check it
out here
11
i

Variable i in memory

Output
1
2
3
4
5
6
7
8
9
10
Output
11
i

Variable i in memory

1
2
3
4
5
6
7
8
9
10

Condition is
checked again
Output
11
i

Variable i in memory

1
2
3
4
5
6
7
8
9
10

Condition
is FALSE
Output
1
11
2
3
i
4
5
Variable i in memory
6
7
Stop the
8
execution of the
9
loop and
10
executes the
statement just
after the loop
Final value of i
after the
complete loop Output
11
i

Variable i in memory

1
2
3
4
5
6
7
8
9
10
Output
11
i

Variable i in memory

1
2
3
4
5
6
7
8
9
10

Final output of
the loop

More Related Content

PPTX
Operators in java
PPT
Union In language C
PPTX
Java interface
PPTX
Exception handling c++
PPTX
Control statements in java
PPTX
Control statement-Selective
PPTX
Conditional statement c++
PPTX
Control flow statements in java
Operators in java
Union In language C
Java interface
Exception handling c++
Control statements in java
Control statement-Selective
Conditional statement c++
Control flow statements in java

What's hot (20)

PPTX
Operators in java
PPT
Java Presentation
PPTX
Union in C programming
PPT
Looping statements in Java
ODP
Exception Handling In Java
PPTX
JAVA LOOP.pptx
PPTX
Data types in java
PPTX
Static Members-Java.pptx
PPTX
Data Types, Variables, and Operators
PPS
String and string buffer
PPT
Java operators
PPT
C# Exceptions Handling
PPTX
for loop in java
PPS
Java Exception handling
PPTX
Inheritance in java
PPTX
Inheritance in JAVA PPT
PDF
Java Programming | Java Tutorial For Beginners | Java Training | Edureka
PPSX
C lecture 4 nested loops and jumping statements slideshare
PPT
Binary operator overloading
PPTX
Operators in java presentation
Operators in java
Java Presentation
Union in C programming
Looping statements in Java
Exception Handling In Java
JAVA LOOP.pptx
Data types in java
Static Members-Java.pptx
Data Types, Variables, and Operators
String and string buffer
Java operators
C# Exceptions Handling
for loop in java
Java Exception handling
Inheritance in java
Inheritance in JAVA PPT
Java Programming | Java Tutorial For Beginners | Java Training | Edureka
C lecture 4 nested loops and jumping statements slideshare
Binary operator overloading
Operators in java presentation
Ad

Viewers also liked (20)

PPTX
Control Statements in Java
PDF
32.java input-output
PPTX
Multi-threaded Programming in JAVA
PPTX
Java string handling
PPT
Operating System Chapter 4 Multithreaded programming
PPTX
Exception handling in Java
PPTX
Operators in java
PPTX
Arrays in Java
PPT
Java inheritance
PPT
Exception handling in java
PPT
Java: Inheritance
PPT
Java Basics
PDF
Java exception handling ppt
PPT
Packages and interfaces
PPTX
Classes, objects in JAVA
PPT
Core java concepts
PPTX
Inheritance
PPT
Java basic
PPT
Core java slides
PPTX
Control statements in Java
Control Statements in Java
32.java input-output
Multi-threaded Programming in JAVA
Java string handling
Operating System Chapter 4 Multithreaded programming
Exception handling in Java
Operators in java
Arrays in Java
Java inheritance
Exception handling in java
Java: Inheritance
Java Basics
Java exception handling ppt
Packages and interfaces
Classes, objects in JAVA
Core java concepts
Inheritance
Java basic
Core java slides
Control statements in Java
Ad

Similar to java programming- control statements (20)

PPTX
Decision Making Statement in C ppt
PPT
control-statements detailed presentation
PPTX
C Programming - Decision making, Looping
PPTX
presentation on powerpoint template.pptx
PDF
UNIT 2 PPT.pdf
PPTX
Control Structures Python like conditions and loops
PPT
_Java__Expressions__and__FlowControl.ppt
PPT
_Java__Expressions__and__FlowControl.ppt
PPTX
Control Statements in Matlab
PPTX
Matlab: Control Statements
PPTX
Chapter 3
DOCX
Chapter 4(1)
PPT
Decision making and looping
PPT
control-statements....ppt - definition
PPTX
Control Statement IN C.pptx
PPT
Visula C# Programming Lecture 4
PPT
control-statements, control-statements, control statement
PPTX
Programming Fundamentals in C++ structures
PPT
2. Control structures with for while and do while.ppt
PDF
controlflowwSoftware Development Fundamentals (SDF) – I ODD 2024 Jaypee Insti...
Decision Making Statement in C ppt
control-statements detailed presentation
C Programming - Decision making, Looping
presentation on powerpoint template.pptx
UNIT 2 PPT.pdf
Control Structures Python like conditions and loops
_Java__Expressions__and__FlowControl.ppt
_Java__Expressions__and__FlowControl.ppt
Control Statements in Matlab
Matlab: Control Statements
Chapter 3
Chapter 4(1)
Decision making and looping
control-statements....ppt - definition
Control Statement IN C.pptx
Visula C# Programming Lecture 4
control-statements, control-statements, control statement
Programming Fundamentals in C++ structures
2. Control structures with for while and do while.ppt
controlflowwSoftware Development Fundamentals (SDF) – I ODD 2024 Jaypee Insti...

More from jyoti_lakhani (20)

PPSX
CG02 Computer Graphic Systems.ppsx
PPTX
Projections.pptx
PPSX
CG04 Color Models.ppsx
PPSX
CG03 Random Raster Scan displays and Color CRTs.ppsx
PPTX
CG02 Computer Graphic Systems.pptx
PPSX
CG01 introduction.ppsx
PDF
Doubly linked list
PDF
Double ended queue
PDF
Tree terminology and introduction to binary tree
PDF
Priority queue
PDF
Ds006 linked list- delete from front
PPSX
Ds06 linked list- insert a node after a given node
PPSX
Ds06 linked list- insert a node at end
PPSX
Ds06 linked list- insert a node at beginning
PPSX
Ds06 linked list- intro and create a node
PPSX
Ds04 abstract data types (adt) jyoti lakhani
PPSX
Ds03 part i algorithms by jyoti lakhani
PPSX
Ds03 algorithms jyoti lakhani
PPSX
Ds02 flow chart and pseudo code
PPSX
Ds01 data structure introduction - by jyoti lakhani
CG02 Computer Graphic Systems.ppsx
Projections.pptx
CG04 Color Models.ppsx
CG03 Random Raster Scan displays and Color CRTs.ppsx
CG02 Computer Graphic Systems.pptx
CG01 introduction.ppsx
Doubly linked list
Double ended queue
Tree terminology and introduction to binary tree
Priority queue
Ds006 linked list- delete from front
Ds06 linked list- insert a node after a given node
Ds06 linked list- insert a node at end
Ds06 linked list- insert a node at beginning
Ds06 linked list- intro and create a node
Ds04 abstract data types (adt) jyoti lakhani
Ds03 part i algorithms by jyoti lakhani
Ds03 algorithms jyoti lakhani
Ds02 flow chart and pseudo code
Ds01 data structure introduction - by jyoti lakhani

Recently uploaded (20)

PDF
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
PDF
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
PPT
Geologic Time for studying geology for geologist
PPTX
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
PPTX
Custom Battery Pack Design Considerations for Performance and Safety
PDF
sbt 2.0: go big (Scala Days 2025 edition)
PPT
What is a Computer? Input Devices /output devices
PDF
UiPath Agentic Automation session 1: RPA to Agents
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
Five Habits of High-Impact Board Members
PDF
How IoT Sensor Integration in 2025 is Transforming Industries Worldwide
PPTX
Build Your First AI Agent with UiPath.pptx
PPTX
The various Industrial Revolutions .pptx
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PPTX
TEXTILE technology diploma scope and career opportunities
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PDF
A proposed approach for plagiarism detection in Myanmar Unicode text
PPTX
Modernising the Digital Integration Hub
PDF
Consumable AI The What, Why & How for Small Teams.pdf
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
Geologic Time for studying geology for geologist
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
Custom Battery Pack Design Considerations for Performance and Safety
sbt 2.0: go big (Scala Days 2025 edition)
What is a Computer? Input Devices /output devices
UiPath Agentic Automation session 1: RPA to Agents
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
Final SEM Unit 1 for mit wpu at pune .pptx
Five Habits of High-Impact Board Members
How IoT Sensor Integration in 2025 is Transforming Industries Worldwide
Build Your First AI Agent with UiPath.pptx
The various Industrial Revolutions .pptx
A contest of sentiment analysis: k-nearest neighbor versus neural network
TEXTILE technology diploma scope and career opportunities
Taming the Chaos: How to Turn Unstructured Data into Decisions
A proposed approach for plagiarism detection in Myanmar Unicode text
Modernising the Digital Integration Hub
Consumable AI The What, Why & How for Small Teams.pdf

java programming- control statements