© Josh Juneau 2017

Josh Juneau, Java 9 Recipes, 10.1007/978-1-4842-1976-8_9

9. Exceptions and Logging

Josh Juneau

(1)Hinckley, Illinois, USA

Exceptions are a way of describing exceptional circumstances within a program. They are an indicator that something unexpected (exceptional) has occurred. For that reason, exceptions are efficient at interrupting the current flow of the program and signaling that there is something that requires attention. As such, programs that utilize exceptions judiciously benefit from a better control flow and become more robust and informative for the user. Even so, using exceptions indiscriminately can cause performance degradation.

Within Java, exceptions can be thrown or caught. Throwing an exception involves indicating ...

Get Java 9 Recipes: A Problem-Solution Approach, Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.