Java Tip 134: When catching exceptions, don’t cast your net too wide

Java’s compile-time checking does a pretty good job of keeping exceptions safely caged—you can’t call a method that throws a checked exception without catching the exception or declaring that your own method throws that exception. (For a great discussion on checked and unchecked exceptions and when to use each, see “Designing with Exceptions” (JavaWorld, 1998).) The compiler will also sometimes stop you from catching an exception that isn’t thrown in the try block, but not always, and not when you need it most. This Java Tip discusses this second compile-time check.

To read this article in full, please click here

\"IT電腦補習
立刻註冊及報名電腦補習課程吧!

Find A Teacher Form:
https://docs.google.com/forms/d/1vREBnX5n262umf4wU5U2pyTwvk9O-JrAgblA-wH9GFQ/viewform?edit_requested=true#responses

Email:
public1989two@gmail.com






www.itsec.hk
www.itsec.vip
www.itseceu.uk