The Nuts and Bolts of the Java Language |
The output of the character-counting program depends on the input you enter for it. Here are the platform-specific instructions for running the character-counting application. When an application reads from the standard input stream, like the character-counting application does, the application blocks and waits for you to type something in. The application continues to wait for input until you give it some indication that the input is complete. To indicate to any program that reads from the standard input stream that you have finished entering characters, at the beginning of a new line type the end-of-input character appropriate for your system. When the character-counting program receives an end-of-input character it prints out the number of characters you typed.In the sample below, the user enters This is a test. followed by the appropriate end-of-input character. In response, the application displays
Input has 16 chars.
At first glance it may appear that the output is incorrect, since This is a test. has only 15 characters. But the user entered a new line as the 16th character.This is a test. Input has 16 chars.
The Nuts and Bolts of the Java Language |