Different Ways of Handling Exceptions

Let's look at a short demo class that allows us to see everything in one place. This example shows different ways of working with code that could generate exceptions. You might not be familiar with working with Java's networking libraries or database libraries. It doesn't matter here. What matters is noticing the different ways that exceptions can be used in your code.

 package net.javagarage.demo.exceptions; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; import java.sql.*; /** * This class demonstrates different ways to write * your methods when you need to deal with exceptions * in them. Any one of them could be most appropriate, * depending ...

Get Java Garage 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.