128 Part II: Writing Your Own Java Programs (Web server)

128 Part II: Writing Your Own Java Programs Figure 6-3 shows you what you get when you run the program of Listing 6-2. (You get exactly what you deserve.) The forstatement in Listing 6-2 starts by setting the countvariable equal to 1. Then the statement tests to make sure that countis less than or equal to 10 (which it certainly is). Then the forstatement dives ahead and executes the printing statements between the curly braces. (At this early stage of the game, the computer prints The value of count is 1.) Finally, the forstatement does that last thing inside its parentheses it adds 1 to the value of count. Figure 6-3: Counting to ten. With countnow equal to 2, the forstatement checks again to make sure that countis less than or equal to 10. (Yes, 2 is smaller than 10.) Because the test turns out okay, the forstatement marches back into the curly braced statements and prints The value of count is 2on the screen. Finally, the forstatement does that last thing inside its parentheses it adds 1 to the value of count, increasing the value of countto 3. And so on. This whole thing keeps being repeated over and over again until, after 10 iterations, the value of countfinally reaches 11. When this happens, the check for countbeing less than or equal to 10 fails, and the loop s execution ends. The computer jumps to whatever statement comes immediately after the forstatement. In Listing 6-2, the computer prints Done!The whole process is illustrated in Figure 6-4. The anatomy of a for statement After the word for, you always put three things in parentheses. The first of these three things is called an initialization, the second is an expression, and the third thing is called an update. for ( initialization ; expression ; update )
As web cam capabilities have been added to instant messaging text chat services such as Yahoo Messenger, AOL Instant Messenger (AIM), MSN Messenger and Skype, one-to-one live video communication over the internet has now reached millions of mainstream PC users worldwide.You can see details on web cam web hosting section.

Leave a Reply