SlideShare a Scribd company logo
Programming in Java
5-day workshop
Loops
Matt Collison
JP Morgan Chase 2021
PiJ1.4: Loops
Session overview
Loops
• for loops
• while loops
break and continue
Loops
• A loop can be used to execute a block of statements repeatedly. If the
repeating time is:
• predictable: usually use for loop
• unpredictable: usually use while or do-while loop
for ( initialization; condition; expression ){ ... }
• Example:
for( int i=1 ; i<10 ; i++ ){
...
}
Alternatives for loops
• Q1: How about only printing the odd numbers smaller than 10?
for ( initialization; condition; expression ){ ... }
for( int i=1; i<10; i++ ){
if( I % 2 != 0 ){
System.out.println( i );
}
}
• Q2: How about printing the numbers in a descending order?
for( int i=9; i>=1; i--){ ... }
for-each loops
for ( Type var : array ) {
...
}
• Example:
int[] numArray = {7,2,6,0}
for ( int i : numArray ) {
System.out.println("number is: " + i);
}
Note: the use of a colon
while and do while loops
while(Boolean expression) {
...
}
do {
...
} while ( <Boolean expression> )
• When the condition becomes false, program control passes to the line
immediately following the loop.
• while loop might not ever run.
• do-while loop runs at least once.
Examples
Calculate the factorial of n (=1*2*...*n) using the three types of loops.
Option 1: for loop:
int n = 5;
int factorial = 1;
for (int number = 1; number <= n; ++number) {
factorial *= number;
}
Examples
Calculate the factorial of n (=1*2*...*n) using the three types of loops.
Option 2: while loop:
int n = 5;
int factorial = 1;
int number = 1;
while (number<=n) {
factorial *= number;
number++; //update
}
Examples
Calculate the factorial of n (=1*2*...*n) using the three types of loops.
Option 3: do-while loop:
int n = 5;
int factorial = 1;
int number = 1;
do{
factorial *= number;
number++; //update
} while (number<=n);
Should we print or return
the factorial?
break and continue
• The break statement is used to jump out of the loop or switch
statement.
• The continue statement is used to skip to the next iteration of the
loop.
break
• Note: Only jump out of the innermost enclosing loop of the statement.
int n = 5;
for ( int i = 1 ; i < n ; i++ ){
for ( int j = 1 ; j < n ; j++ ){
if ( j > i) {
break;
} else {
System.out.print( j + " ");
}
} // break comes here if it runs
System.out.println();
}
What is the output?
continue
• The continue statement skips the current iteration of a loop. Only skip the
innermost enclosing loop of the statement.
for (int i=0;i<=10;i++){
if (i==5) {
continue;
}
System.out.println(i);
}
System.out.println("Done!");
1. What is the output?
2. What is the output if replacing continue; with break;?
3. What is the output if replacing continue; with return;?
Summary
• Loop control statements
• for loop
• for ( int i=0; i<n; i++) { … }
• while loop and do-while loop
• Both for and while loops might not ever run, do-while loop runs at least once
• break and continue
• break: jump out of the loop or switch statement.
• continue: skips the current iteration of a loop.
• Both only have effect on the innermost enclosing loop.
Learning resources
The workshop homepage
https://mcollison.github.io/JPMC-java-intro-2021/
The course materials
https://mcollison.github.io/java-programming-foundations/
• Session worksheets – updated each week
Additional resources
• Think Java: How to think like a computer scientist
• Allen B Downey (O’Reilly Press)
• Available under Creative Commons license
• https://greenteapress.com/wp/think-java-2e/
• Oracle central Java Documentation –
https://docs.oracle.com/javase/8/docs/api/
• Other sources:
• W3Schools Java - https://www.w3schools.com/java/
• stack overflow - https://stackoverflow.com/
• Coding bat - https://codingbat.com/java

More Related Content

Similar to Pi j1.4 loops

python ppt.pptx
python ppt.pptxpython ppt.pptx
python ppt.pptx
ssuserd10678
 
Week2 ch4 part1edited 2020
Week2 ch4 part1edited 2020Week2 ch4 part1edited 2020
Week2 ch4 part1edited 2020
Osama Ghandour Geris
 
Ch6 Loops
Ch6 LoopsCh6 Loops
Ch6 Loops
SzeChingChen
 
Control structures repetition
Control structures   repetitionControl structures   repetition
Control structures repetition
Online
 
Chapter 9 Flow Of Control Knowledge Boat.pdf
Chapter 9 Flow Of Control Knowledge Boat.pdfChapter 9 Flow Of Control Knowledge Boat.pdf
Chapter 9 Flow Of Control Knowledge Boat.pdf
MATHESH20
 
Loops c++
Loops c++Loops c++
Loops c++
Shivani Singh
 
03 conditions loops
03   conditions loops03   conditions loops
03 conditions loops
Manzoor ALam
 
Object oriented programming18 control structures looping
Object oriented programming18 control structures loopingObject oriented programming18 control structures looping
Object oriented programming18 control structures looping
Vaibhav Khanna
 
This is all about control flow in python intruducing the Break and Continue.pptx
This is all about control flow in python intruducing the Break and Continue.pptxThis is all about control flow in python intruducing the Break and Continue.pptx
This is all about control flow in python intruducing the Break and Continue.pptx
elezearrepil1
 
Loops in Python.pptx
Loops in Python.pptxLoops in Python.pptx
Java Programming: Loops
Java Programming: LoopsJava Programming: Loops
Java Programming: Loops
Karwan Mustafa Kareem
 
C Sharp Jn (3)
C Sharp Jn (3)C Sharp Jn (3)
C Sharp Jn (3)
jahanullah
 
Operators loops conditional and statements
Operators loops conditional and statementsOperators loops conditional and statements
Operators loops conditional and statements
Vladislav Hadzhiyski
 
Loops
LoopsLoops
Loops
Kamran
 
3. Flow Controls in C (Part II).pdf
3. Flow Controls in C (Part II).pdf3. Flow Controls in C (Part II).pdf
3. Flow Controls in C (Part II).pdf
santosh147365
 
M C6java6
M C6java6M C6java6
M C6java6
mbruggen
 
Cs1123 6 loops
Cs1123 6 loopsCs1123 6 loops
Cs1123 6 loops
TAlha MAlik
 
Looping statements
Looping statementsLooping statements
Looping statements
AbhishekMondal42
 
Loops IN COMPUTER SCIENCE STANDARD 11 BY KR
Loops IN COMPUTER SCIENCE STANDARD 11 BY KRLoops IN COMPUTER SCIENCE STANDARD 11 BY KR
Loops IN COMPUTER SCIENCE STANDARD 11 BY KR
Krishna Raj
 
12 lec 12 loop
12 lec 12 loop 12 lec 12 loop
12 lec 12 loop
kapil078
 

Similar to Pi j1.4 loops (20)

python ppt.pptx
python ppt.pptxpython ppt.pptx
python ppt.pptx
 
Week2 ch4 part1edited 2020
Week2 ch4 part1edited 2020Week2 ch4 part1edited 2020
Week2 ch4 part1edited 2020
 
Ch6 Loops
Ch6 LoopsCh6 Loops
Ch6 Loops
 
Control structures repetition
Control structures   repetitionControl structures   repetition
Control structures repetition
 
Chapter 9 Flow Of Control Knowledge Boat.pdf
Chapter 9 Flow Of Control Knowledge Boat.pdfChapter 9 Flow Of Control Knowledge Boat.pdf
Chapter 9 Flow Of Control Knowledge Boat.pdf
 
Loops c++
Loops c++Loops c++
Loops c++
 
03 conditions loops
03   conditions loops03   conditions loops
03 conditions loops
 
Object oriented programming18 control structures looping
Object oriented programming18 control structures loopingObject oriented programming18 control structures looping
Object oriented programming18 control structures looping
 
This is all about control flow in python intruducing the Break and Continue.pptx
This is all about control flow in python intruducing the Break and Continue.pptxThis is all about control flow in python intruducing the Break and Continue.pptx
This is all about control flow in python intruducing the Break and Continue.pptx
 
Loops in Python.pptx
Loops in Python.pptxLoops in Python.pptx
Loops in Python.pptx
 
Java Programming: Loops
Java Programming: LoopsJava Programming: Loops
Java Programming: Loops
 
C Sharp Jn (3)
C Sharp Jn (3)C Sharp Jn (3)
C Sharp Jn (3)
 
Operators loops conditional and statements
Operators loops conditional and statementsOperators loops conditional and statements
Operators loops conditional and statements
 
Loops
LoopsLoops
Loops
 
3. Flow Controls in C (Part II).pdf
3. Flow Controls in C (Part II).pdf3. Flow Controls in C (Part II).pdf
3. Flow Controls in C (Part II).pdf
 
M C6java6
M C6java6M C6java6
M C6java6
 
Cs1123 6 loops
Cs1123 6 loopsCs1123 6 loops
Cs1123 6 loops
 
Looping statements
Looping statementsLooping statements
Looping statements
 
Loops IN COMPUTER SCIENCE STANDARD 11 BY KR
Loops IN COMPUTER SCIENCE STANDARD 11 BY KRLoops IN COMPUTER SCIENCE STANDARD 11 BY KR
Loops IN COMPUTER SCIENCE STANDARD 11 BY KR
 
12 lec 12 loop
12 lec 12 loop 12 lec 12 loop
12 lec 12 loop
 

More from mcollison

Pi j4.2 software-reliability
Pi j4.2 software-reliabilityPi j4.2 software-reliability
Pi j4.2 software-reliability
mcollison
 
Pi j4.1 packages
Pi j4.1 packagesPi j4.1 packages
Pi j4.1 packages
mcollison
 
Pi j3.1 inheritance
Pi j3.1 inheritancePi j3.1 inheritance
Pi j3.1 inheritance
mcollison
 
Pi j3.2 polymorphism
Pi j3.2 polymorphismPi j3.2 polymorphism
Pi j3.2 polymorphism
mcollison
 
Pi j3.4 data-structures
Pi j3.4 data-structuresPi j3.4 data-structures
Pi j3.4 data-structures
mcollison
 
Pi j2.3 objects
Pi j2.3 objectsPi j2.3 objects
Pi j2.3 objects
mcollison
 
Pi j2.2 classes
Pi j2.2 classesPi j2.2 classes
Pi j2.2 classes
mcollison
 
Pi j1.0 workshop-introduction
Pi j1.0 workshop-introductionPi j1.0 workshop-introduction
Pi j1.0 workshop-introduction
mcollison
 
Pi j1.3 operators
Pi j1.3 operatorsPi j1.3 operators
Pi j1.3 operators
mcollison
 
Pi j1.2 variable-assignment
Pi j1.2 variable-assignmentPi j1.2 variable-assignment
Pi j1.2 variable-assignment
mcollison
 
Pi j1.1 what-is-java
Pi j1.1 what-is-javaPi j1.1 what-is-java
Pi j1.1 what-is-java
mcollison
 

More from mcollison (11)

Pi j4.2 software-reliability
Pi j4.2 software-reliabilityPi j4.2 software-reliability
Pi j4.2 software-reliability
 
Pi j4.1 packages
Pi j4.1 packagesPi j4.1 packages
Pi j4.1 packages
 
Pi j3.1 inheritance
Pi j3.1 inheritancePi j3.1 inheritance
Pi j3.1 inheritance
 
Pi j3.2 polymorphism
Pi j3.2 polymorphismPi j3.2 polymorphism
Pi j3.2 polymorphism
 
Pi j3.4 data-structures
Pi j3.4 data-structuresPi j3.4 data-structures
Pi j3.4 data-structures
 
Pi j2.3 objects
Pi j2.3 objectsPi j2.3 objects
Pi j2.3 objects
 
Pi j2.2 classes
Pi j2.2 classesPi j2.2 classes
Pi j2.2 classes
 
Pi j1.0 workshop-introduction
Pi j1.0 workshop-introductionPi j1.0 workshop-introduction
Pi j1.0 workshop-introduction
 
Pi j1.3 operators
Pi j1.3 operatorsPi j1.3 operators
Pi j1.3 operators
 
Pi j1.2 variable-assignment
Pi j1.2 variable-assignmentPi j1.2 variable-assignment
Pi j1.2 variable-assignment
 
Pi j1.1 what-is-java
Pi j1.1 what-is-javaPi j1.1 what-is-java
Pi j1.1 what-is-java
 

Recently uploaded

A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 

Recently uploaded (20)

A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 

Pi j1.4 loops

  • 1. Programming in Java 5-day workshop Loops Matt Collison JP Morgan Chase 2021 PiJ1.4: Loops
  • 2. Session overview Loops • for loops • while loops break and continue
  • 3. Loops • A loop can be used to execute a block of statements repeatedly. If the repeating time is: • predictable: usually use for loop • unpredictable: usually use while or do-while loop for ( initialization; condition; expression ){ ... } • Example: for( int i=1 ; i<10 ; i++ ){ ... }
  • 4. Alternatives for loops • Q1: How about only printing the odd numbers smaller than 10? for ( initialization; condition; expression ){ ... } for( int i=1; i<10; i++ ){ if( I % 2 != 0 ){ System.out.println( i ); } } • Q2: How about printing the numbers in a descending order? for( int i=9; i>=1; i--){ ... }
  • 5. for-each loops for ( Type var : array ) { ... } • Example: int[] numArray = {7,2,6,0} for ( int i : numArray ) { System.out.println("number is: " + i); } Note: the use of a colon
  • 6. while and do while loops while(Boolean expression) { ... } do { ... } while ( <Boolean expression> ) • When the condition becomes false, program control passes to the line immediately following the loop. • while loop might not ever run. • do-while loop runs at least once.
  • 7. Examples Calculate the factorial of n (=1*2*...*n) using the three types of loops. Option 1: for loop: int n = 5; int factorial = 1; for (int number = 1; number <= n; ++number) { factorial *= number; }
  • 8. Examples Calculate the factorial of n (=1*2*...*n) using the three types of loops. Option 2: while loop: int n = 5; int factorial = 1; int number = 1; while (number<=n) { factorial *= number; number++; //update }
  • 9. Examples Calculate the factorial of n (=1*2*...*n) using the three types of loops. Option 3: do-while loop: int n = 5; int factorial = 1; int number = 1; do{ factorial *= number; number++; //update } while (number<=n); Should we print or return the factorial?
  • 10. break and continue • The break statement is used to jump out of the loop or switch statement. • The continue statement is used to skip to the next iteration of the loop.
  • 11. break • Note: Only jump out of the innermost enclosing loop of the statement. int n = 5; for ( int i = 1 ; i < n ; i++ ){ for ( int j = 1 ; j < n ; j++ ){ if ( j > i) { break; } else { System.out.print( j + " "); } } // break comes here if it runs System.out.println(); } What is the output?
  • 12. continue • The continue statement skips the current iteration of a loop. Only skip the innermost enclosing loop of the statement. for (int i=0;i<=10;i++){ if (i==5) { continue; } System.out.println(i); } System.out.println("Done!"); 1. What is the output? 2. What is the output if replacing continue; with break;? 3. What is the output if replacing continue; with return;?
  • 13. Summary • Loop control statements • for loop • for ( int i=0; i<n; i++) { … } • while loop and do-while loop • Both for and while loops might not ever run, do-while loop runs at least once • break and continue • break: jump out of the loop or switch statement. • continue: skips the current iteration of a loop. • Both only have effect on the innermost enclosing loop.
  • 14. Learning resources The workshop homepage https://mcollison.github.io/JPMC-java-intro-2021/ The course materials https://mcollison.github.io/java-programming-foundations/ • Session worksheets – updated each week
  • 15. Additional resources • Think Java: How to think like a computer scientist • Allen B Downey (O’Reilly Press) • Available under Creative Commons license • https://greenteapress.com/wp/think-java-2e/ • Oracle central Java Documentation – https://docs.oracle.com/javase/8/docs/api/ • Other sources: • W3Schools Java - https://www.w3schools.com/java/ • stack overflow - https://stackoverflow.com/ • Coding bat - https://codingbat.com/java

Editor's Notes

  1. Answer: 1 1 2 1 2 3 1 2 3 4
  2. Answer 1: 0 1 2 3 4 Done Answer 2: 0 1 2 3 4 Answer 3: 0 1 2 3 4
  3. All resources hang from the ELE pages. How many of you have looked through them?