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

More Related Content

PPTX
Control flow statements in java
yugandhar vadlamudi
 
PPT
M C6java6
mbruggen
 
PDF
Java conditional statements
Kuppusamy P
 
PPTX
Chapter 2 : Programming with Java Statements
It Academy
 
PPTX
Java Decision Control
Jayfee Ramos
 
PPT
M C6java5
mbruggen
 
DOC
Jumping statements
Suneel Dogra
 
PPT
Repetition Structure
PRN USM
 
Control flow statements in java
yugandhar vadlamudi
 
M C6java6
mbruggen
 
Java conditional statements
Kuppusamy P
 
Chapter 2 : Programming with Java Statements
It Academy
 
Java Decision Control
Jayfee Ramos
 
M C6java5
mbruggen
 
Jumping statements
Suneel Dogra
 
Repetition Structure
PRN USM
 

What's hot (20)

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

Viewers also liked (8)

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

Similar to Java control flow statements (20)

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

More from Future Programming (7)

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

Recently uploaded (20)

PPTX
Odoo 18 Sales_ Managing Quotation Validity
Celine George
 
DOCX
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
PDF
Sunset Boulevard Student Revision Booklet
jpinnuck
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
PPTX
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
PPTX
ACUTE NASOPHARYNGITIS. pptx
AneetaSharma15
 
PPTX
PREVENTIVE PEDIATRIC. pptx
AneetaSharma15
 
PPTX
vedic maths in python:unleasing ancient wisdom with modern code
mistrymuskan14
 
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
PDF
Wings of Fire Book by Dr. A.P.J Abdul Kalam Full PDF
hetalvaishnav93
 
PPTX
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
RAKESH SAJJAN
 
DOCX
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
PDF
Arihant Class 10 All in One Maths full pdf
sajal kumar
 
PDF
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
PPTX
How to Manage Global Discount in Odoo 18 POS
Celine George
 
PPTX
Congenital Hypothyroidism pptx
AneetaSharma15
 
PDF
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
PPTX
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
PPTX
Care of patients with elImination deviation.pptx
AneetaSharma15
 
Odoo 18 Sales_ Managing Quotation Validity
Celine George
 
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
Sunset Boulevard Student Revision Booklet
jpinnuck
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
ACUTE NASOPHARYNGITIS. pptx
AneetaSharma15
 
PREVENTIVE PEDIATRIC. pptx
AneetaSharma15
 
vedic maths in python:unleasing ancient wisdom with modern code
mistrymuskan14
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
Wings of Fire Book by Dr. A.P.J Abdul Kalam Full PDF
hetalvaishnav93
 
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
RAKESH SAJJAN
 
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
Arihant Class 10 All in One Maths full pdf
sajal kumar
 
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
How to Manage Global Discount in Odoo 18 POS
Celine George
 
Congenital Hypothyroidism pptx
AneetaSharma15
 
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
Care of patients with elImination deviation.pptx
AneetaSharma15
 

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.