Note: the program gives different results for each system. On UNIX when you press the return key, you get a single character:
- UNIX
% java Count This is a test. ^D Input has 16 chars.Use the control-D character (type D while holding down the control key) to indicate to a program reading from the standard input stream that you have finished entering input. The control-D character is often written as
^D
.- DOS shell (Windows 95/NT)
C:\> java Count This is a test. ^Z Input has 17 chars.Use the control-Z character (type Z while holding down the control key) to indicate to a program reading from the standard input stream that you have finished entering input. Or you can press the
F6
key. The control-Z character is often written as^Z
.- MacOS
- First, the Count application brings up a window prompting you for command line arguments. Press the return key to indicate that there aren't any. Next, the Count application brings up a window prompting you to type characters into standard input. Type This is a test. and press the return key. To indicate that you are finished typing, press the return key again.
The program displays the results in a window.
Input has 15 chars.\n
. On Windows 95/NT when you press the return key, you get two characters:\r\n
. And on MacOS, the return key is not passed to the application.