SlideShare a Scribd company logo
JAVAJAVA
CONTROLCONTROL
STATEMENTSSTATEMENTS
ByBy
Hiren K. VaghasiyaHiren K. Vaghasiya
CONTROL STATEMENTSCONTROL STATEMENTS
• if elseif else
• switchswitch
• whilewhile
• do whiledo while
• forfor
• breakbreak
• continuecontinue
• returnreturn
• Labeled break, continueLabeled break, continue
IF-ELSEIF-ELSE
if(conditional_statement){if(conditional_statement){
statement to be executed if conditions becomes truestatement to be executed if conditions becomes true
}else{}else{
statements to be executed if the above condition becomesstatements to be executed if the above condition becomes
falsefalse
}}
SWITCHSWITCH
switch(byte/short/int){switch(byte/short/int){
case expression:case expression:
statementsstatements
case expression:case expression:
statementsstatements
default:default:
statementstatement
}}
WHILE - LOOPWHILE - LOOP
while(condition_statementwhile(condition_statementtrue){true){
Statements to be executed when the condition becomes true andStatements to be executed when the condition becomes true and
execute them repeatedly until condition becomes false.execute them repeatedly until condition becomes false.
}}
E.g.E.g.
int x =2;int x =2;
while(x>5){while(x>5){
system.out.println(“value of x:”+x);system.out.println(“value of x:”+x);
x++;x++;
}}
DO WHILE - LOOPDO WHILE - LOOP
do{do{
statements to be executed at least once without looking atstatements to be executed at least once without looking at
the condition.the condition.
The statements will be exeucted until the condition becomesThe statements will be exeucted until the condition becomes
true.true.
}while(condition_statement);}while(condition_statement);
FOR - LOOPFOR - LOOP
for(for(initializationinitialization; condition;; condition; increment/decrementincrement/decrement){){
statements to be executed until the condition becomesstatements to be executed until the condition becomes falsefalse
}}
E.g:E.g:
for(int x=0; x<10;x++){for(int x=0; x<10;x++){
System.out.println(“value of x:”+x);System.out.println(“value of x:”+x);
}}
BREAKBREAK
• Break is used in the loops and when executed, the control ofBreak is used in the loops and when executed, the control of
the execution will come out of the loop.the execution will come out of the loop.
for(int i=0;i<50;i++){
if(i%13==0){
break;
}
System.out.println(“Value of i:”+i);
}
CONTINUECONTINUE
• Continue makes the loop to skip the current execution andContinue makes the loop to skip the current execution and
continues with the next iteration.continues with the next iteration.
for(int i=0;i<50;i++){for(int i=0;i<50;i++){
if(i%13==0){if(i%13==0){
continue;continue;
}}
System.out.println(“Value of i:”+i);System.out.println(“Value of i:”+i);
}}
RETURNRETURN
• returnreturn statement can be used to cause execution to branch statement can be used to cause execution to branch
back to the caller of the method.back to the caller of the method.
LABELED BREAK,CONTINUELABELED BREAK,CONTINUE
• Labeled break and continue statements will break orLabeled break and continue statements will break or
continue from the loop that is mentioned.continue from the loop that is mentioned.
• Used in nested loops.Used in nested loops.
WWW.FUTUREPROGRAMMING.INWWW.FUTUREPROGRAMMING.IN
The end
The end
Ad

Recommended

Control flow statements in java
Control flow statements in java
yugandhar vadlamudi
 
M C6java6
M C6java6
mbruggen
 
Java conditional statements
Java conditional statements
Kuppusamy P
 
Chapter 2 : Programming with Java Statements
Chapter 2 : Programming with Java Statements
It Academy
 
Java Decision Control
Java Decision Control
Jayfee Ramos
 
M C6java5
M C6java5
mbruggen
 
Jumping statements
Jumping statements
Suneel Dogra
 
Repetition Structure
Repetition Structure
PRN USM
 
Control statements
Control statements
Kanwalpreet Kaur
 
Control structures in java
Control structures in java
VINOTH R
 
Java if else condition - powerpoint persentation
Java if else condition - powerpoint persentation
Maneesha Caldera
 
Decision making and looping
Decision making and looping
Hossain Md Shakhawat
 
Control statements in java
Control statements in java
Madishetty Prathibha
 
Flow of control ppt
Flow of control ppt
Indraprastha Institute of Information Technology
 
Control statement in c
Control statement in c
baabtra.com - No. 1 supplier of quality freshers
 
Control structures repetition
Control structures repetition
Online
 
C++ chapter 4
C++ chapter 4
SHRIRANG PINJARKAR
 
Control statements in java programmng
Control statements in java programmng
Savitribai Phule Pune University
 
Control statements anil
Control statements anil
Anil Dutt
 
Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)
Muhammad Tahir Bashir
 
nuts and bolts of c++
nuts and bolts of c++
guestfb6ada
 
java programming- control statements
java programming- control statements
jyoti_lakhani
 
Control structures ii
Control structures ii
Ahmad Idrees
 
Control structures i
Control structures i
Ahmad Idrees
 
Java loops for, while and do...while
Java loops for, while and do...while
Jayfee Ramos
 
Switch statement, break statement, go to statement
Switch statement, break statement, go to statement
Raj Parekh
 
Program control statements in c#
Program control statements in c#
Dr.Neeraj Kumar Pandey
 
Decision Making Statement in C ppt
Decision Making Statement in C ppt
MANJUTRIPATHI7
 
Arrays Basics
Arrays Basics
Nikhil Pandit
 
Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)
EngineerBabu
 

More Related Content

What's hot (20)

Control statements
Control statements
Kanwalpreet Kaur
 
Control structures in java
Control structures in java
VINOTH R
 
Java if else condition - powerpoint persentation
Java if else condition - powerpoint persentation
Maneesha Caldera
 
Decision making and looping
Decision making and looping
Hossain Md Shakhawat
 
Control statements in java
Control statements in java
Madishetty Prathibha
 
Flow of control ppt
Flow of control ppt
Indraprastha Institute of Information Technology
 
Control statement in c
Control statement in c
baabtra.com - No. 1 supplier of quality freshers
 
Control structures repetition
Control structures repetition
Online
 
C++ chapter 4
C++ chapter 4
SHRIRANG PINJARKAR
 
Control statements in java programmng
Control statements in java programmng
Savitribai Phule Pune University
 
Control statements anil
Control statements anil
Anil Dutt
 
Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)
Muhammad Tahir Bashir
 
nuts and bolts of c++
nuts and bolts of c++
guestfb6ada
 
java programming- control statements
java programming- control statements
jyoti_lakhani
 
Control structures ii
Control structures ii
Ahmad Idrees
 
Control structures i
Control structures i
Ahmad Idrees
 
Java loops for, while and do...while
Java loops for, while and do...while
Jayfee Ramos
 
Switch statement, break statement, go to statement
Switch statement, break statement, go to statement
Raj Parekh
 
Program control statements in c#
Program control statements in c#
Dr.Neeraj Kumar Pandey
 
Decision Making Statement in C ppt
Decision Making Statement in C ppt
MANJUTRIPATHI7
 
Control structures in java
Control structures in java
VINOTH R
 
Java if else condition - powerpoint persentation
Java if else condition - powerpoint persentation
Maneesha Caldera
 
Control structures repetition
Control structures repetition
Online
 
Control statements anil
Control statements anil
Anil Dutt
 
Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)
Muhammad Tahir Bashir
 
nuts and bolts of c++
nuts and bolts of c++
guestfb6ada
 
java programming- control statements
java programming- control statements
jyoti_lakhani
 
Control structures ii
Control structures ii
Ahmad Idrees
 
Control structures i
Control structures i
Ahmad Idrees
 
Java loops for, while and do...while
Java loops for, while and do...while
Jayfee Ramos
 
Switch statement, break statement, go to statement
Switch statement, break statement, go to statement
Raj Parekh
 
Decision Making Statement in C ppt
Decision Making Statement in C ppt
MANJUTRIPATHI7
 

Viewers also liked (8)

Arrays Basics
Arrays Basics
Nikhil Pandit
 
Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)
EngineerBabu
 
Arrays
Arrays
archikabhatia
 
Java basic
Java basic
Sonam Sharma
 
Introduction to Java
Introduction to Java
Ashita Agrawal
 
Constants, Variables and Data Types in Java
Constants, Variables and Data Types in Java
Abhilash Nair
 
Operators in java
Operators in java
Then Murugeshwari
 
Introduction to java
Introduction to java
Veerabadra Badra
 
Ad

Similar to Java control flow statements (20)

Computer programming 2 Lesson 8
Computer programming 2 Lesson 8
MLG College of Learning, Inc
 
Control statements
Control statements
raksharao
 
05. Control Structures.ppt
05. Control Structures.ppt
AyushDut
 
Pj01 5-exceution control flow
Pj01 5-exceution control flow
SasidharaRaoMarrapu
 
dizital pods session 5-loops.pptx
dizital pods session 5-loops.pptx
VijayKumarLokanadam
 
java notes.pdf
java notes.pdf
RajkumarHarishchandr1
 
07 flow control
07 flow control
dhrubo kayal
 
Control structures in Java
Control structures in Java
Ravi_Kant_Sahu
 
Java chapter 5
Java chapter 5
Mukesh Tekwani
 
control statements
control statements
Azeem Sultan
 
DAY_1.2.pptx
DAY_1.2.pptx
ishasharma835109
 
Java chapter 3
Java chapter 3
Abdii Rashid
 
Computer Programming, Loops using Java
Computer Programming, Loops using Java
Mahmoud Alfarra
 
Programming in java - Concepts- Operators- Control statements-Expressions
Programming in java - Concepts- Operators- Control statements-Expressions
LovelitJose
 
Control flow statements in java web applications
Control flow statements in java web applications
RajithKarunarathne1
 
Control structures
Control structures
Gehad Enayat
 
130707833146508191
130707833146508191
Tanzeel Ahmad
 
Chapter 5 java
Chapter 5 java
Ahmad sohail Kakar
 
Java 2.pptx
Java 2.pptx
usmanusman720379
 
controlStatement.pptx, CONTROL STATEMENTS IN JAVA
controlStatement.pptx, CONTROL STATEMENTS IN JAVA
DrNeetuSharma5
 
Control statements
Control statements
raksharao
 
05. Control Structures.ppt
05. Control Structures.ppt
AyushDut
 
dizital pods session 5-loops.pptx
dizital pods session 5-loops.pptx
VijayKumarLokanadam
 
Control structures in Java
Control structures in Java
Ravi_Kant_Sahu
 
control statements
control statements
Azeem Sultan
 
Computer Programming, Loops using Java
Computer Programming, Loops using Java
Mahmoud Alfarra
 
Programming in java - Concepts- Operators- Control statements-Expressions
Programming in java - Concepts- Operators- Control statements-Expressions
LovelitJose
 
Control flow statements in java web applications
Control flow statements in java web applications
RajithKarunarathne1
 
Control structures
Control structures
Gehad Enayat
 
controlStatement.pptx, CONTROL STATEMENTS IN JAVA
controlStatement.pptx, CONTROL STATEMENTS IN JAVA
DrNeetuSharma5
 
Ad

More from Future Programming (7)

Measures of central tendency
Measures of central tendency
Future Programming
 
Osi model in networking
Osi model in networking
Future Programming
 
Osi model in networking
Osi model in networking
Future Programming
 
Characteristics of tps
Characteristics of tps
Future Programming
 
Network Topologies
Network Topologies
Future Programming
 
Transaction processing system future programming
Transaction processing system future programming
Future Programming
 
C - Pattern - Code - [Future Programming]
C - Pattern - Code - [Future Programming]
Future Programming
 

Recently uploaded (20)

BINARY files CSV files JSON files with example.pptx
BINARY files CSV files JSON files with example.pptx
Ramakrishna Reddy Bijjam
 
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
Ronisha Das
 
“THE BEST CLASS IN SCHOOL”. _
“THE BEST CLASS IN SCHOOL”. _
Colégio Santa Teresinha
 
Pests of Maize: An comprehensive overview.pptx
Pests of Maize: An comprehensive overview.pptx
Arshad Shaikh
 
LDM Recording Presents Yogi Goddess by LDMMIA
LDM Recording Presents Yogi Goddess by LDMMIA
LDM & Mia eStudios
 
Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado
 
How to Implement Least Package Removal Strategy in Odoo 18 Inventory
How to Implement Least Package Removal Strategy in Odoo 18 Inventory
Celine George
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
Kweku Zurek
 
Communicable Diseases and National Health Programs – Unit 9 | B.Sc Nursing 5t...
Communicable Diseases and National Health Programs – Unit 9 | B.Sc Nursing 5t...
RAKESH SAJJAN
 
LDMMIA Practitioner Student Reiki Yoga S2 Video PDF Without Yogi Goddess
LDMMIA Practitioner Student Reiki Yoga S2 Video PDF Without Yogi Goddess
LDM & Mia eStudios
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
Sourav Kr Podder
 
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
 
How to Manage Inventory Movement in Odoo 18 POS
How to Manage Inventory Movement in Odoo 18 POS
Celine George
 
Health Care Planning and Organization of Health Care at Various Levels – Unit...
Health Care Planning and Organization of Health Care at Various Levels – Unit...
RAKESH SAJJAN
 
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Rajdeep Bavaliya
 
GEOGRAPHY-Study Material [ Class 10th] .pdf
GEOGRAPHY-Study Material [ Class 10th] .pdf
SHERAZ AHMAD LONE
 
K12 Tableau User Group virtual event June 18, 2025
K12 Tableau User Group virtual event June 18, 2025
dogden2
 
2025 June Year 9 Presentation: Subject selection.pptx
2025 June Year 9 Presentation: Subject selection.pptx
mansk2
 
BINARY files CSV files JSON files with example.pptx
BINARY files CSV files JSON files with example.pptx
Ramakrishna Reddy Bijjam
 
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
Ronisha Das
 
Pests of Maize: An comprehensive overview.pptx
Pests of Maize: An comprehensive overview.pptx
Arshad Shaikh
 
LDM Recording Presents Yogi Goddess by LDMMIA
LDM Recording Presents Yogi Goddess by LDMMIA
LDM & Mia eStudios
 
Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado
 
How to Implement Least Package Removal Strategy in Odoo 18 Inventory
How to Implement Least Package Removal Strategy in Odoo 18 Inventory
Celine George
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
Kweku Zurek
 
Communicable Diseases and National Health Programs – Unit 9 | B.Sc Nursing 5t...
Communicable Diseases and National Health Programs – Unit 9 | B.Sc Nursing 5t...
RAKESH SAJJAN
 
LDMMIA Practitioner Student Reiki Yoga S2 Video PDF Without Yogi Goddess
LDMMIA Practitioner Student Reiki Yoga S2 Video PDF Without Yogi Goddess
LDM & Mia eStudios
 
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
Sourav Kr Podder
 
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
 
How to Manage Inventory Movement in Odoo 18 POS
How to Manage Inventory Movement in Odoo 18 POS
Celine George
 
Health Care Planning and Organization of Health Care at Various Levels – Unit...
Health Care Planning and Organization of Health Care at Various Levels – Unit...
RAKESH SAJJAN
 
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Rajdeep Bavaliya
 
GEOGRAPHY-Study Material [ Class 10th] .pdf
GEOGRAPHY-Study Material [ Class 10th] .pdf
SHERAZ AHMAD LONE
 
K12 Tableau User Group virtual event June 18, 2025
K12 Tableau User Group virtual event June 18, 2025
dogden2
 
2025 June Year 9 Presentation: Subject selection.pptx
2025 June Year 9 Presentation: Subject selection.pptx
mansk2
 

Java control flow statements

  • 2. CONTROL STATEMENTSCONTROL STATEMENTS • if elseif else • switchswitch • whilewhile • do whiledo while • forfor • breakbreak • continuecontinue • returnreturn • Labeled break, continueLabeled break, continue
  • 3. IF-ELSEIF-ELSE if(conditional_statement){if(conditional_statement){ statement to be executed if conditions becomes truestatement to be executed if conditions becomes true }else{}else{ statements to be executed if the above condition becomesstatements to be executed if the above condition becomes falsefalse }}
  • 4. SWITCHSWITCH switch(byte/short/int){switch(byte/short/int){ case expression:case expression: statementsstatements case expression:case expression: statementsstatements default:default: statementstatement }}
  • 5. WHILE - LOOPWHILE - LOOP while(condition_statementwhile(condition_statementtrue){true){ Statements to be executed when the condition becomes true andStatements to be executed when the condition becomes true and execute them repeatedly until condition becomes false.execute them repeatedly until condition becomes false. }} E.g.E.g. int x =2;int x =2; while(x>5){while(x>5){ system.out.println(“value of x:”+x);system.out.println(“value of x:”+x); x++;x++; }}
  • 6. DO WHILE - LOOPDO WHILE - LOOP do{do{ statements to be executed at least once without looking atstatements to be executed at least once without looking at the condition.the condition. The statements will be exeucted until the condition becomesThe statements will be exeucted until the condition becomes true.true. }while(condition_statement);}while(condition_statement);
  • 7. FOR - LOOPFOR - LOOP for(for(initializationinitialization; condition;; condition; increment/decrementincrement/decrement){){ statements to be executed until the condition becomesstatements to be executed until the condition becomes falsefalse }} E.g:E.g: for(int x=0; x<10;x++){for(int x=0; x<10;x++){ System.out.println(“value of x:”+x);System.out.println(“value of x:”+x); }}
  • 8. BREAKBREAK • Break is used in the loops and when executed, the control ofBreak is used in the loops and when executed, the control of the execution will come out of the loop.the execution will come out of the loop. for(int i=0;i<50;i++){ if(i%13==0){ break; } System.out.println(“Value of i:”+i); }
  • 9. CONTINUECONTINUE • Continue makes the loop to skip the current execution andContinue makes the loop to skip the current execution and continues with the next iteration.continues with the next iteration. for(int i=0;i<50;i++){for(int i=0;i<50;i++){ if(i%13==0){if(i%13==0){ continue;continue; }} System.out.println(“Value of i:”+i);System.out.println(“Value of i:”+i); }}
  • 10. RETURNRETURN • returnreturn statement can be used to cause execution to branch statement can be used to cause execution to branch back to the caller of the method.back to the caller of the method.
  • 11. LABELED BREAK,CONTINUELABELED BREAK,CONTINUE • Labeled break and continue statements will break orLabeled break and continue statements will break or continue from the loop that is mentioned.continue from the loop that is mentioned. • Used in nested loops.Used in nested loops.