Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: Exception Usage

The most common exceptions to catch are number conversion exceptions and I/O exceptions.

Tutorial Details:

Suggestions for catching exceptions
If you catch an exception, do something. Don't silence exceptions.
Some programs catch exceptions, then do nothing with them. This is almost always a mistake, and the underlying error should be fixed.
There are a few cases where you might want to silently ignore an exception. For example, changing the Look and Feel of the GUI may cause an exception. There's nothing to be done about it, so you don't want to stop execution.

Put larger blocks of code in a try clause
Altho an exception is generated by a single statement, an entire block of code is usually affected. It is often better to put the try around the block, not just single statements.
Don't catch exceptions that you can't really do anything with
If you can't do anything useful, don't catch an exception. Let someone higher up catch it.


 

Rate Tutorial:
http://www.roseindia.net/java/java-tips/flow/exceptions/02exceptions.shtml

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
Exception Usage

View Tutorial:
Exception Usage

Related Tutorials:

Java Tip 70: Create objects from jar files! - JavaWorld - March 1999
Java Tip 70: Create objects from jar files! - JavaWorld - March 1999
 
Build your own ObjectPool in Java to boost app speed - JavaWorld - June 1998
Build your own ObjectPool in Java to boost app speed - JavaWorld - June 1998
 
Java Tip 76: An alternative to the deep copy technique
Java Tip 76: An alternative to the deep copy technique
 
Java performance programming, Part 2: The cost of casting - JavaWorld December 1999
Java performance programming, Part 2: The cost of casting - JavaWorld December 1999
 
Use JDBC for industrial-strength performance, Part 1 - JavaWorld January 2000
Use JDBC for industrial-strength performance, Part 1 - JavaWorld January 2000
 
Frameworks save the day - JavaWorld September 2000
Frameworks save the day - JavaWorld September 2000
 
Retrofit existing applications with RMI - JavaWorld January 2001
Retrofit existing applications with RMI - JavaWorld January 2001
 
Robust event logging with Syslog - JavaWorld April 2001
Robust event logging with Syslog - JavaWorld April 2001
 
Trace your steps in Java 1.4
Trace your steps in Java 1.4
 
I want my AOP!, Part 3
I want my AOP!, Part 3
 
Exceptions: Don't get thrown for a loss
Exceptions: Don't get thrown for a loss
 
Repair invalid cached services in the Service Locator pattern
Repair invalid cached services in the Service Locator pattern
 
Profiling CPU usage from within a Java application
Profiling CPU usage from within a Java application
 
Cracking Java byte-code encryption
Cracking Java byte-code encryption
 
Beware the dangers of generic Exceptions
Beware the dangers of generic Exceptions
 
A simple sample, but interesting enough
A simple sample, but interesting enough
 
JXMLPad 2.3
JXMLPad 2.3 JXMLPad is a pure Swing java component/framework for editing XML/XHTML document.
 
JFindReplace
JFindReplace is a "find and replace" swing component working with various options (regulation expression, incremental mode...) and standard text components like JTextArea, JTextPane, JEditorPane....
 
JXMLPad 3.1 FC
JXMLPad is a pure Swing java component/framework for editing XML/XHTML document.
 
Reader-Submitted Tech Tip: Peeking Under Mount Points
Find out how to use NFS to inspect the underlying directory structure if the reported disk usage seems inconsistent.
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.