Program Flow  «Prev  Next»
Lesson 1

Introduction to Controlling Program Flow

This module explores the flow of Java programs and shows you how to alter program flow using
  1. branches
  2. and loops.

You will begin the module by learning how to use conditional branches such as if-else and switch statements. You will then move on to learn the basics of loops, including how to use the for loop. From there, you will learn about while loops, do loops, and you will get some tips on how to control loops in general.

Module learning objectives

After completing the module, you will have the skills and knowledge necessary to:
  1. Branch conditionally using if-else and switch statements
  2. Understand and use for loops, while loops, and do loops
  3. Make informed decisions about the effectiveness of different loops
  4. Break out of loops using the break statement
Can you imagine trying to write code using a language that did not give you a way to execute statements conditionally? Flow control is a key part of any useful programming language, and Java offers several ways to accomplish it. Some statements, such as if statements and for loops, are common to most languages. But Java also throws in a couple of flow control features you might not have used before, namely exceptions and assertions.