Presentation is loading. Please wait.

Presentation is loading. Please wait.

Java Programming Constructs 3 MIS 3023 Business Programming Concepts II The University of Tulsa Professor: Akhilesh Bajaj All slides in this presentation.

Similar presentations


Presentation on theme: "Java Programming Constructs 3 MIS 3023 Business Programming Concepts II The University of Tulsa Professor: Akhilesh Bajaj All slides in this presentation."— Presentation transcript:

1 Java Programming Constructs 3 MIS 3023 Business Programming Concepts II The University of Tulsa Professor: Akhilesh Bajaj All slides in this presentation ©Akhilesh Bajaj, 2006. All rights reserved

2 Objectives Continue to understand programming constructs in Java: -the while loop -the do-while loop -the for loop Look at the break statement Look at the continue statement Let’s get started!

3 Nesting for Loops To get the above output, we can use:

4 Nesting for Loops A program that will list all the letters contained in a string and will also count the number of different letters.

5 The break Statement Syntax: break; Breaks out of a loop or switch statement If used in an if statement, then the if statement HAS to be in a loop or a switch, and the program will break out of that container loop or switch statement. Can we write the above with a for loop?

6 The break Statement We can also create a labeled break, to break out of nested loops. label_name: loop1 loop 2 loop3 break label_name; end loop3 end loop2 end loop1 Will break out of all the loops and proceed with the next statement below the 3 labeled loops. See example of ListLetters.java

7 The continue Statement Syntax: continue; Continues with the next iteration of the loop. See program ContinueDemo.java The continue statement can also refer to a label, if we want to continue the next iteration of an outer loop.

8 Fun In Class Example Write a program called MultiplicationTable.java that prints the multiplication table for a particular integer, input by the user, times 1 till times 12 of that integer.


Download ppt "Java Programming Constructs 3 MIS 3023 Business Programming Concepts II The University of Tulsa Professor: Akhilesh Bajaj All slides in this presentation."

Similar presentations


Ads by Google