In the best of all possible worlds, nothing would ever go wrong in a Java program. In reality, your program may have to deal with many unexpected problems, such as missing files, bad user input, dropped network connections, and (unfortunately) programming errors. Java provides an elegant approach to handling these problems with the exception mechanism. This mechanism uses exception and error objects to handle everything from an end-of-file condition to an out-of-memory error. It also provides a mechanism that strongly encourages other users of your code to include exception handling. This is in contrast with other languages, such as C, that leave it up to the programmers to implement their own version of exception handling.