Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

Try to catch me

Does exception handling impair performance?

  • Print
  • Feedback

Q Does adding exception handling (try/catch block) affect a program's performance?

A Try/catch blocks add a trivial amount of overhead to your programs. In essence, try/catch blocks come free, unless an exception actually throws -- handling a thrown exception can be expensive. For that reason, you should use exceptions only to handle error conditions. That is, you should never use exceptions to control program flow.

You should also avoid placing try/catch blocks within a loop. Though trivial once, try/catch blocks can add up when performed many times inside a loop.

  • Print
  • Feedback
What is Tech Briefcase?
TechBriefcase is a new, free service where IT Professionals can Search, Store and Share IT white papers and content like this. Learn more
Bookmark content
Speed up your research efforts with content across the web.
Search and Store
Find the white papers you need. Create folders for any topic.
View Anywhere
Open your briefcase on your iPhone, tablet or desktop. Share with colleagues.
Don't have an account yet?

Resources