Chapter 6 Controlling Program Flow with Loops In
Chapter 6 Controlling Program Flow with Loops In This Chapter Using basic looping Counting as you loop Impressing your friends with Java s enhanced loops In 1966, the company that brings you Head & Shoulders shampoo made history. On the back of the bottle, the directions for using the shampoo read, LATHER-RINSE-REPEAT. Never before had a complete set of directions (for doing anything, let alone shampooing your hair) been summarized so succinctly. People in the direction-writing business hailed this as a monumental achievement. Directions like these stood in stark contrast to others of the time. (For instance, the first sentence on a can of bug spray read, Turn this can so that it points away from your face. Duh!) Aside from their brevity, the thing that made the Head & Shoulders directions so cool was that, with three simple words, they managed to capture a notion that s at the heart of all instruction-giving the notion of repetition. That last word, REPEAT, took an otherwise bland instructional drone and turned it into a sophisticated recipe for action. The fundamental idea is that when you re following directions, you don t just follow one instruction after another. Instead, you take turns in the road. You make decisions ( If HAIR IS DRY, then USE CONDITIONER, ) and you go into loops ( LATHER-RINSE, and then LATHER-RINSE again. ). In computer programming, you use decision making and looping all the time. This chapter explores looping in Java.
Every our account comes with web mail client, free virus scanner, free anti-spam tool, free web templates and much more. For complete list of all our virtual web hosting features check our Virtual Web Hosting section.