Java Reference
In-Depth Information
SR 11.12
If the input is 42 the program defined OutOfRangeException is thrown in
main , the message “Input value is out of range.” is printed along with the
stack trace that consists of just information about CreatingExceptions.
main , and the program terminates. If the input is - 3 , the same thing
happens. If the input is the string “thirty,” then a library defined
InputMismatchException is thrown, a stack trace that consists of infor-
mation about five methods is printed, and the program terminates. I/O
exceptions are the topic of the next section of this textbook.
11.6 I/O Exceptions
SR 11.13
A stream is a sequential series of bytes that serves as a source of input
or a destination for output.
SR 11.14
The standard I/O streams in Java are System.in , the standard input
stream; System.out , the standard output stream; and System.err ,
the standard error stream. Usually, standard input comes from the
keyboard and standard output and error go to a default window on
the monitor screen.
SR 11.15
The Stream object we have been using explicitly throughout this topic
is the System.out object. We have used it when printing output from
our programs. Sometimes we have also used the System.in object, to
create Scanner objects for reading input from the user.
SR 11.16
The main method definition of the CreatingExceptions program
does not include a throws InputMismatchException clause, because
the Scanner class takes care of that—there is no need to repeat code
in the main method when it is already included in a helper class.
SR 11.17
The main method definition of the TestData program does not include
a throws FileNotFoundException clause, because the FileWriter
class takes care of that that—there is no need to repeat code in the
main method when it is already included in a helper class.
SR 11.18
If the PrintWriter constructor of the TestDate class is passed the fw
object instead of the bw object, the program still works. The only dif-
ference is that the program does not use the buffering capabilities of
the BufferedWriter class and therefore the processing may not be as
efficient.
11.7 Tool Tips and Mnemonics
SR 11.19
A tool tip is a small amount of text that can be set up to appear when
the cursor comes to rest on a component. It usually gives information
about that component.
Search WWH ::




Custom Search