Error handling is an important feature in any programming language. A good error handling mechanism makes it easier for programmers to write robust applications and prevent bugs from creeping in. In some languages, programmers use multiple if statements to detect all possible conditions that might lead to an error. This could make code excessively complex and lead to spaghetti like code.
Java offers the try statement as a nice approach to error handling. With this strategy, part of the code that could potentially lead to an error is isolated in a block. Should an error occur, this error is caught and resolved locally. This chapter teaches you this.
An error in Java is often referred to as an exception, ...