Tomcat web hosting - 104 Part II: Writing Your Own Java Programs
104 Part II: Writing Your Own Java Programs I can also beef up my program s importdeclarations, as I do in Listings 5-2 and 5-3. Other than that, I have very little leeway. As you read on in this book, you ll start recognizing the patterns behind these three lines of code, so I don t clutter up this section with all the details. For now, you can just copy these three lines and keep the following in mind: When you import java.util.Scanner, you don t use the word static. Importing Scanneris different from importing System.out. When you import java.lang.System.out, you use the word static. (See Listing 5-1.) For the real story on the word static, see Chapter 10. The name System.in stands for the keyboard. To get characters from someplace other than the keyboard, you can type something other than System.ininside the parentheses. What else can you put inside the parentheses? For some ideas, see Chapter 8. When you expect the user to type an int value (a whole number of some kind), use nextInt(). If you expect the user to type a doublevalue (a number containing a decimal point), use nextDouble(). If you expect the user to type true or false, use nextBoolean(). If you expect the user to type a word (a word like Barry, Java, or Hello), use next(). For an example in which the user types a word, see Listing 5-3. For an example in which the user types a single character, see Listing 6-4 in Chapter 6. For an example in which a program reads an entire line of text (all in one big gulp), see Chapter 8. You can get several values from the keyboard, one after another. To do this, use the myScanner.nextInt()code several times. To see a program that reads more than one value from the keyboard, go to Listing 5-4. Creating randomness Achieving real randomness is surprisingly difficult. Mathematician Persi Diaconis says that if you flip a coin several times, always starting with the head side up, you re likely to toss heads more often than tails. If you toss several more times, always starting with the tail side up, you re likely to toss tails more often than heads. In other words, coin tossing isn t really fair.* * Diaconis, Persi. The Search for Randomness. American Association for the Advancement of Science annual meeting. Seattle. 14 Feb. 2004.
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.