Controlling the flow of execution is perhaps the most important aspect of any programming language. Control flow allows you to direct the execution of your program down different paths in response to the inputs to your system. A proper construction of loops and branches in your code provides your program a map to follow as it performs its work. You can also think about control flow like a stoplight. The logic in a traffic system directs the flow of traffic based on the current conditions and the timing mechanism that drive it. Your programs must also have the capability to start, stop, and direct their flow of execution. Without the variety of control constructs found in modern programming languages, you would be limited to developing simple applications, or developing complex ones using an abundance of redundant and inefficient code. This chapter introduces you to the control mechanisms available in Java and describes how you use them to develop dynamic programs. |