Q&A

Q1:I'm still not sure I understand the differences between exceptions, errors, and runtime exceptions. Is there another way of looking at them?
A1: Errors are caused by dynamic linking or virtual machine problems, and are thus too low-level for most programs to care about—or be able to handle even if they did care about them. Runtime exceptions are generated by the normal execution of Java code, and although they occasionally reflect a condition you will want to handle explicitly, more often they reflect a coding mistake made by the programmer, and thus simply need to print an error to help flag that mistake. Exceptions that are non-runtime exceptions (IOException exceptions, for example) are conditions that, because of their nature, should ...

Get Sams Teach Yourself Java 2 in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.