Lecture 20
11
Exceptions
•Java’s object oriented mechanism for error handling
•more powerful, more flexible than using return
•Java keywords   try, catch, throw
•in class: banking system, JOI with Exceptions
•for hw: improve Exception handling in Juno 7
•Model
–in client: instead of testing a returned value
•try, hoping for the best
•prepare to pick up the pieces if necessary (catch)
–in code where the error may occur:
•detect error
•create a new Exception and throw it