January 2014
Intermediate to advanced
736 pages
70h 43m
English
The application in Fig. H.2, which is based on Fig. H.1, uses exception handling to process any ArithmeticExceptions and InputMistmatchExceptions that arise. The application still prompts the user for two integers and passes them to method quotient, which calculates the quotient and returns an int result. This version of the application uses exception handling so that if the user makes a mistake, the program catches and handles (i.e., deals with) the exception—in this case, allowing the user to enter the input again.
1 // Fig. H.2: DivideByZeroWithExceptionHandling.java 2 // Handling ArithmeticExceptions and InputMismatchExceptions.
Read now
Unlock full access