CS 151 Lecture 10: Sections 5.1-5.2
Document Summary
The order in which statements are executed in a running program is called the flow of control. Unless otherwise specified, the execution of a program proceeds in a linear fashion. A running program starts at the first programming statement and moves down one statement at a time until the program is complete. Invoking a method alters the flow of control. When a method is called, control jumps to the code defined for that method. When the method completes, control returns to the place in the calling method where the invocation was made, and processing continues from there. Conditionals and loops allow us to control the flow of execution through a method. A conditional statement is sometimes called a selection statement, because it allows us to choose which statement will be executed next (if, if-else, switch) Each decision is based on a boolean expression (also called a condition), which is an expression that evaluates to either true or false.