Results 1 to 2 of 2
Thread: Why use Try?
- 12-18-2013, 01:31 AM #1Senior Member
- Join Date
- Jan 2013
- Rep Power
- 12-18-2013, 01:42 AM #2
Re: Why use Try?
First of all, the word "method" has a very specific meaning in Java. And 'try' is not a method.
The basic idea is that when a method is declared to throw a checked exception, the programmer must deal with it in some way. This reduces runtime bugs. Here's a brief overview: Try Statements in Java - For Dummies
In general, you should only catch exceptions if you can do something about them. Otherwise, declare your own method to throw them. And never catch and exception and then completely ignore it. At least print the stack trace.Get in the habit of using standard Java naming conventions!